小编Aym*_*the的帖子

在 F# 中调用多行命名参数的方法

我有一些 F# 代码,它调用用 C# 编写的带有大量参数的方法。

为了使事情清晰易读,我在调用方法时使用命名参数:

let request = Models.UserService.CreateUserRequest(
    email = "email@example.com",
    password = "password",
    title = "title",
    firstname = "firstname",
    lastname = "lastname",
    nickname = "nickname",
    locale = "locale",
    birthDate = "birthdate",
    currency = "USD",
    ipAddress = "127.0.0.1",
    address = address,
    mobilePhone = "+1 123 456 7890"
)
Run Code Online (Sandbox Code Playgroud)

但是我收到有关缩进的警告:

warning FS0058: Possible incorrect indentation: this token is offside of context started at position (30:19). Try indenting this token further or using standard formatting conventions.
Run Code Online (Sandbox Code Playgroud)

显然,如果我不使用命名参数或将所有内容放在一行中,警告就会消失。但我想以一种清晰易读的方式格式化它。 …

f# c#-to-f#

4
推荐指数
1
解决办法
620
查看次数

标签 统计

c#-to-f# ×1

f# ×1