-
-
Save joshi1983/0c683b5d933bd1c59714f3b8581df3e1 to your computer and use it in GitHub Desktop.
Fixed misspelled return keyword in Decrement method
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public Maybe<int> Decrement(int number) | |
{ | |
if (number <= 0) | |
{ | |
return Maybe<int>.None; | |
} | |
return Maybe<int>(number-1); | |
} | |
Maybe<int> test1 = Decrement(100); | |
test1.Match( | |
some: x => Console.Writeline($"It has a value: {x}"), | |
none: () => Console.Wreiteline("It has no value") | |
); | |
// output from test1 would be: "It has a value: 99" | |
Maybe<int> test2 = Decrement(0); | |
test1.Match( | |
some: x => Console.Writeline($"It has a value: {x}"), | |
none: () => Console.Wreiteline("It has no value") | |
); | |
// output from test2 would be: "It has no value" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment