F#:如何使用 "with" 构造函数获取更多值
F#: how to use "with" constructor for more values
在 F# 中我可以做到:
let card = { anotherCard with Cost = 4 }
但我想做:
let card = { anotherCard with Cost = 4 with WinPoints = 5 }
或者至少有一些班轮,现在我必须:
let cardTemp = { anotherCard with Cost = 4 }
let card = { cardTemp with WinPoints = 5 }
您可以用分号分隔多个字段设置器:
let card = { anotherCard with Cost = 4; WinPoints = 5 }
您也可以将字段放在单独的行中(没有分号分隔符):
let card = { anotherCard with
Cost = 4
WinPoints = 5 }
在 F# 中我可以做到:
let card = { anotherCard with Cost = 4 }
但我想做:
let card = { anotherCard with Cost = 4 with WinPoints = 5 }
或者至少有一些班轮,现在我必须:
let cardTemp = { anotherCard with Cost = 4 }
let card = { cardTemp with WinPoints = 5 }
您可以用分号分隔多个字段设置器:
let card = { anotherCard with Cost = 4; WinPoints = 5 }
您也可以将字段放在单独的行中(没有分号分隔符):
let card = { anotherCard with
Cost = 4
WinPoints = 5 }