더 클래스 :선택적 매개 변수
type NotAbstract =
class
new : unit -> NotAbstract
member WithOptionalParameters : x:int * ?y:int -> int
end
그러나이 작동하지 않습니다 :
[<AbstractClass>]
type AbstractExample() =
abstract WithOptionalParameters: int * ?int -> int /// Ouch...
type NotAbstract() =
inherit AbstractExample()
override this.WithOptionalParameters (x, ?y) =
let y = defaultArg y 10
x + y
하는 방법을 쓸 수
type NotAbstract() =
member this.WithOptionalParameters (x, ?y) =
let y = defaultArg y 10
x + y
는 다음과 같은 유형의 서명이 선택적 매개 변수가있는 함수의 추상 정의에 적절한 유형 서명? 나는 어떤 힌트도 찾지 못했다 here.
PS : 나는 (비슷한) 결과가 polymorphism
F # 방식 Nullable 유형 대신 (더 원시적 인) Option 유형을 사용하는 것입니다. –