对于此类定义:
type Foo(f1: int, f2: string) =
member x.F1 = f1
member x.F2 = PostProcess f2
Run Code Online (Sandbox Code Playgroud)
每次访问f2时都会调用PostProcess(一些字符串操作函数)吗?如果答案是肯定的,我想避免它,那么什么是正确的习惯用法?这个是推荐的吗?这对我来说有点过于冗长.
type Foo =
val F1: int
val F2: string
new (f1, f2) as this =
{F1 = f1; F2 = f2;}
then this.F2 = PostProcess(f2) |> ignore
Run Code Online (Sandbox Code Playgroud)