We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent d4a209d commit 067f012Copy full SHA for 067f012
Exercises/Chapter03/Solutions.cs
@@ -81,12 +81,14 @@ public AppConfig(NameValueCollection source)
81
}
82
83
public Option<T> Get<T>(string key)
84
- => Some((T)Convert.ChangeType(source[key], typeof(T)));
+ => source[key] == null
85
+ ? None
86
+ : Some((T)Convert.ChangeType(source[key], typeof(T)));
87
88
public T Get<T>(string key, T defaultValue)
89
=> Get<T>(key).Match(
- Some: value => value,
- None: () => defaultValue);
90
+ () => defaultValue,
91
+ (value) => value);
92
93
94
0 commit comments