假设我们有以下类型:
type Message {
text : Option<string>
}
type Update {
msg : Option<Message>
}
Run Code Online (Sandbox Code Playgroud)
如何在一行中匹配它,就像在 C# 中使用 null 条件运算符 ie 一样update?.msg?.text?
有没有办法做到这一点?:
match msg, msg.text with
| Some msg, Some txt -> ...
| None -> ...
Run Code Online (Sandbox Code Playgroud)
因为我不想编写 2 个嵌套的匹配表达式。