3 people like it.
Like the snippet!
Nullable Refs without using AllowNullLiteral
Nullable Refs without using AllowNullLiteral
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
|
let (@?) (a:'a) (b:'a Lazy) : 'a =
if System.Object.ReferenceEquals(box a, null)
then b.Value
else a
type Foo() =
class
end
let x = Unchecked.defaultof<Foo>
let z = x @? lazy Foo()
|
val a : 'a
val b : Lazy<'a>
Multiple items
active recognizer Lazy: Lazy<'T> -> 'T
Full name: Microsoft.FSharp.Core.ExtraTopLevelOperators.( |Lazy| )
--------------------
type Lazy<'T> = System.Lazy<'T>
Full name: Microsoft.FSharp.Control.Lazy<_>
namespace System
Multiple items
type Object =
new : unit -> obj
member Equals : obj:obj -> bool
member GetHashCode : unit -> int
member GetType : unit -> Type
member ToString : unit -> string
static member Equals : objA:obj * objB:obj -> bool
static member ReferenceEquals : objA:obj * objB:obj -> bool
Full name: System.Object
--------------------
System.Object() : unit
System.Object.ReferenceEquals(objA: obj, objB: obj) : bool
val box : value:'T -> obj
Full name: Microsoft.FSharp.Core.Operators.box
property System.Lazy.Value: 'a
Multiple items
type Foo =
new : unit -> Foo
Full name: Script.Foo
--------------------
new : unit -> Foo
val x : Foo
Full name: Script.x
module Unchecked
from Microsoft.FSharp.Core.Operators
val defaultof<'T> : 'T
Full name: Microsoft.FSharp.Core.Operators.Unchecked.defaultof
val z : Foo
Full name: Script.z
More information