连接字符串数组,并在另一个字符串前添加F#
||
例如,我有一个字符串数组行
lines = [| \"hello\"; \"world\" |]
我想创建一个字符串行,该行将以\“ code = \”字符串开头的行中的元素连接起来。例如,我需要从lines数组中获取字符串code=\"helloworld\"
。
我可以用此代码获得连接的字符串
let concatenatedLine = lines |> String.concat \"\"
并且我测试了此代码以在\“ code = \”字符串之前添加如下代码,但是出现了error FS0001: The type \'string\' is not compatible with the type \'seq<string>\'
错误。
let concatenatedLine = \"code=\" + lines |> String.concat \"\"
这怎么了?
没有找到相关结果
已邀请:
2 个回复
刷骸码
比
绑定更牢固,因此您需要添加一些括号:
否则,编译器将解析表达式,如下所示:
芭隘的盘石