DO绑定用于在不定义函数或类型的情况下执行代码。您可以使用F#中的DO绑定来编写独立的代码。
type DoBindingClass() = class printf "hello" //error : unexpected identifier in member definition end
type DoBindingClass() = class do printf "Hello FSharp" end new DoBindingClass()
输出:
Hello FSharp
祝学习愉快!(内容编辑有误?请选中要编辑内容 -> 右键 -> 修改 -> 提交!)