Last active
May 13, 2022 16:38
-
-
Save jbtule/8477768 to your computer and use it in GitHub Desktop.
Revisions
-
jbtule revised this gist
Jan 29, 2014 . 1 changed file with 3 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,9 +1,9 @@ //inspired by http://stackoverflow.com/a/2812306/637783 type NullCoalesce = static member Coalesce(a: 'a option, b: 'a Lazy) = match a with Some a -> a | _ -> b.Value static member Coalesce(a: 'a Nullable, b: 'a Lazy) = if a.HasValue then a.Value else b.Value static member Coalesce(a: 'a when 'a:null, b: 'a Lazy) = match a with null -> b.Value | _ -> a let inline nullCoalesceHelper< ^t, ^a, ^b, ^c when (^t or ^a) : (static member Coalesce : ^a * ^b -> ^c)> a b = ((^t or ^a) : (static member Coalesce : ^a * ^b -> ^c) (a, b)) -
jbtule revised this gist
Jan 18, 2014 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,9 +1,9 @@ //inspired by http://stackoverflow.com/a/2812306/637783 type NullCoalesce = static member Coalesce(a: 'a option, b: unit -> 'a) = match a with Some a -> a | _ -> b() static member Coalesce(a: 'a Nullable, b: unit -> 'a) = if a.HasValue then a.Value else b() static member Coalesce(a: 'a when 'a:null, b: unit -> 'a) = match a with null -> b() | _ -> a let inline nullCoalesceHelper< ^t, ^a, ^b, ^c when (^t or ^a) : (static member Coalesce : ^a * ^b -> ^c)> a b = ((^t or ^a) : (static member Coalesce : ^a * ^b -> ^c) (a, b)) -
jbtule revised this gist
Jan 17, 2014 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,5 @@ //inspired by http://stackoverflow.com/a/2812306/637783 type NullCoalesce = static member Coalesce(a: 'a option, b: unit -> 'a) = if a.IsSome then a.Value else b() static member Coalesce(a: 'a Nullable, b: unit -> 'a) = if a.HasValue then a.Value else b() -
jbtule revised this gist
Jan 17, 2014 . 1 changed file with 3 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,9 +1,7 @@ type NullCoalesce = static member Coalesce(a: 'a option, b: unit -> 'a) = if a.IsSome then a.Value else b() static member Coalesce(a: 'a Nullable, b: unit -> 'a) = if a.HasValue then a.Value else b() static member Coalesce(a: 'a when 'a:null, b: unit -> 'a) = if a <> null then a else b() let inline nullCoalesceHelper< ^t, ^a, ^b, ^c when (^t or ^a) : (static member Coalesce : ^a * ^b -> ^c)> a b = ((^t or ^a) : (static member Coalesce : ^a * ^b -> ^c) (a, b)) -
jbtule created this gist
Jan 17, 2014 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,11 @@ //inspired by http://stackoverflow.com/a/2812306/637783 type NullCoalesce = static member Coalesce(a: 'a option, b: 'a) = if a.IsSome then a.Value else b static member Coalesce(a: 'a Nullable, b: 'a) = if a.HasValue then a.Value else b static member Coalesce(a: 'a when 'a:null, b: 'a) = if a <> null then a else b let inline nullCoalesceHelper< ^t, ^a, ^b, ^c when (^t or ^a) : (static member Coalesce : ^a * ^b -> ^c)> a b = ((^t or ^a) : (static member Coalesce : ^a * ^b -> ^c) (a, b)) let inline (|??) a b = nullCoalesceHelper<NullCoalesce, _, _, _> a b