파이프 라인 연산자에서 모듈 및 정적 멤버 함수의 함수를 사용할 수 있습니다. 비 정적 멤버 함수와 함께 사용할 수 있습니까?멤버 함수가있는 파이프 라인 연산자
내 클래스 :
type MyClass =
class
new() = {}
member this.isZero(number: int): bool =
number = 0
static member returnInt(): int =
33
end
정적 멤버 사용 : 비 정적 멤버 사용
MyClass.returnInt() |> Console.WriteLine // prints 33
을 : 나는에서 비 정적 기능을 사용하려면
let foo = new MyClass()
foo.isZero(2) |> Console.WriteLine // prints false
을 내 목적. 구문이 잘못되었습니다.
let foo = new MyClass()
foo |> member MyClass.isZero(2) |> Console.WriteLine
F #의 명확한 구문을 사용하려고합니다.
" 비 정적 멤버 사용 "은하지 않습니까? 'member'는 실제 멤버 선언에서 사용되는 곳이 아닙니다. – TeaDrivenDev
OP가이 일을 시도하고 있다고 생각합니다. https://fslang.uservoice.com/forums/245727-f-language/suggestions/5663326-syntax-for-turning-properties-into-functions 아니, 가능하지 않습니다. . 당신의 예제에서,'foo.isZero (2)'를하는 것이 잘못된 이유는 무엇입니까? –