You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Now I'm seeing an error with .GetValueOrDefault() when I provide it a non-null default.
stringmetaTitle= Maybe
.From(WebPageMetaTitle).MapNullOrWhiteSpaceAsNone().IfNoValue(BlogPostPageBlogPostContent
.TryFirst().Bind(c => Maybe.From(c.ListableItemTitle).MapNullOrWhiteSpaceAsNone())).GetValueOrDefault("");// ERROR: Converting null literal or possible null value to non-nullable type.
Workarounds
It is unfortunate that I now need to do one of the following
.GetValueOrDefault("") ?? "";
Create my own extension .GetValueOrDefaultNotNull(""); that is typed as public T GetValueOrDefaultNotNull(T defaultValue = default(T))
.GetValueOrDefault("")!;
.TryGetValue(out string? val) ? val : "";
.Match(v => v, _ => ""); - for some reason the overload resolution no longer works here and I get the compilation error Only assignment, call, increment, decrement, await, and new object expressions can be used as a statement
The text was updated successfully, but these errors were encountered:
Environment
Types
WebPageMetaTitle
-string
BlogPostPageBlogPostContent
-IEnumerable<T>
ListableItemTitle
-string
Here's my custom extension
Example
Now I'm seeing an error with
.GetValueOrDefault()
when I provide it a non-null default.Workarounds
It is unfortunate that I now need to do one of the following
.GetValueOrDefault("") ?? "";
.GetValueOrDefaultNotNull("");
that is typed aspublic T GetValueOrDefaultNotNull(T defaultValue = default(T))
.GetValueOrDefault("")!;
.TryGetValue(out string? val) ? val : "";
.Match(v => v, _ => "");
- for some reason the overload resolution no longer works here and I get the compilation errorOnly assignment, call, increment, decrement, await, and new object expressions can be used as a statement
The text was updated successfully, but these errors were encountered: