【激突】関数型言語 VS オブジェクト指向言語2
■ このスレッドは過去ログ倉庫に格納されています
0764デフォルトの名無しさん
2012/05/13(日) 20:29:54.03nilと値じゃなくてoption型使ってるけど
type System.Int32 with
member x.Execute func = match x with 0 -> None | n -> func() |> Some
> (0).Execute (fun () -> "zero");;
val it : string option = None
> (1).Execute (fun () -> "one");;
val it : string option = Some "one"
> (1 - 1).Execute (fun () -> 1 - 1);;
val it : int option = None
■ このスレッドは過去ログ倉庫に格納されています