From fa814ce2a4d85a6dd5994f7ba8d35b046093ffb8 Mon Sep 17 00:00:00 2001 From: Brian Rourke Boll Date: Wed, 7 Aug 2024 10:21:26 -0400 Subject: [PATCH] =?UTF-8?q?`Nullable.Value`=20=E2=86=92=20`Nullable.GetVal?= =?UTF-8?q?ueOrDefault`?= 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