From cff62661225be34297240dd438e6aa79321a7ce3 Mon Sep 17 00:00:00 2001 From: Brian Rourke Boll Date: Mon, 12 Aug 2024 11:49:50 -0400 Subject: [PATCH] =?UTF-8?q?`Nullable.Value`=20=E2=86=92=20`Nullable.GetVal?= =?UTF-8?q?ueOrDefault`=20(#17504)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * We are already checking `Nullable.HasValue` before accessing `Nullable.Value`, so it is safe to call `Nullable.GetValueOrDefault`, which does not do an additional check, unlike `Nullable.Value`. --- src/FSharp.Core/option.fs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/FSharp.Core/option.fs b/src/FSharp.Core/option.fs index ba8256580ec..1b29141df64 100644 --- a/src/FSharp.Core/option.fs +++ b/src/FSharp.Core/option.fs @@ -148,7 +148,7 @@ module Option = [] let inline ofNullable (value: System.Nullable<'T>) = if value.HasValue then - Some value.Value + Some (value.GetValueOrDefault()) else None @@ -338,7 +338,7 @@ module ValueOption = [] let inline ofNullable (value: System.Nullable<'T>) = if value.HasValue then - ValueSome value.Value + ValueSome (value.GetValueOrDefault()) else ValueNone