Created
August 27, 2012 12:24
-
-
Save jsakamoto/3487987 to your computer and use it in GitHub Desktop.
しかしこれはビルドエラー(F#のレコード型(下記 MyFile)はnullになるはずがない)。でもprintfnの行を外すとビルドは通るので実行してデバッガで見るとnullになってる。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
open System.IO | |
open System.Linq | |
type MyFile = {Name:string; Size:int64} | |
let toMyFile (f:FileInfo) = {Name=f.Name; Size=f.Length} | |
let dir = new DirectoryInfo("c:\\") | |
let fileOfFoo = | |
dir.GetFiles() | |
|> Array.map toMyFile | |
|> fun x -> x.FirstOrDefault(fun f -> f.Name = "foo") | |
printfn "%s" (if fileOfFoo = null then "null!" else "exists!") | |
// The type 'MyFile' does not have 'null' as a proper value |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment