Skip to content

Commit 067f012

Browse files
committed
fixed solution to exercise 3.5
1 parent d4a209d commit 067f012

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

Exercises/Chapter03/Solutions.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,14 @@ public AppConfig(NameValueCollection source)
8181
}
8282

8383
public Option<T> Get<T>(string key)
84-
=> Some((T)Convert.ChangeType(source[key], typeof(T)));
84+
=> source[key] == null
85+
? None
86+
: Some((T)Convert.ChangeType(source[key], typeof(T)));
8587

8688
public T Get<T>(string key, T defaultValue)
8789
=> Get<T>(key).Match(
88-
Some: value => value,
89-
None: () => defaultValue);
90+
() => defaultValue,
91+
(value) => value);
9092
}
9193
}
9294
}

0 commit comments

Comments
 (0)