@@ -9,7 +9,11 @@ module Obj =
99 /// <param name =" source " >The source object.</param >
1010 /// <returns >The source if it is not null; otherwise, the specified default value.</returns >
1111 /// <remarks >The default value is evaluated eagerly.</remarks >
12+ #if NET9_ 0_ OR_ GREATER && ! FABLE_ COMPILER
13+ let defaultValue value ( source : 'T | null ) : 'T =
14+ #else
1215 let defaultValue value ( source : 'T ) : 'T =
16+ #endif
1317 match source with
1418 | null -> value
1519 | value -> value
@@ -19,7 +23,11 @@ module Obj =
1923 /// <param name =" source " >The source object.</param >
2024 /// <returns >The source if it is not null; otherwise, the result of invoking the specified function.</returns >
2125 /// <remarks >The fNull function is only invoked if the source is null.</remarks >
26+ #if NET9_ 0_ OR_ GREATER && ! FABLE_ COMPILER
27+ let inline defaultWith ( [<InlineIfLambda>] fNull : unit -> 'T ) ( source : 'T | null ) : 'T =
28+ #else
2229 let inline defaultWith ( [<InlineIfLambda>] fNull : unit -> 'T ) ( source : 'T ) : 'T =
30+ #endif
2331 match source with
2432 | null -> fNull ()
2533 | value -> value
@@ -30,7 +38,11 @@ module Obj =
3038 /// <param name =" source " >The source object.</param >
3139 /// <returns >The result of applying fValue to the source if it is not null; otherwise, the result of applying fNull.</returns >
3240 /// <remarks >Only one of the functions is invoked based on the nullity of the source.</remarks >
41+ #if NET9_ 0_ OR_ GREATER && ! FABLE_ COMPILER
42+ let inline either ( [<InlineIfLambda>] fValue : 'T -> 'U ) ( [<InlineIfLambda>] fNull : unit -> 'U ) ( source : 'T | null ) : 'U =
43+ #else
3344 let inline either ( [<InlineIfLambda>] fValue : 'T -> 'U ) ( [<InlineIfLambda>] fNull : unit -> 'U ) ( source : 'T ) : 'U =
45+ #endif
3446 match source with
3547 | null -> fNull ()
3648 | value -> fValue value
0 commit comments