Skip to content

Commit f2a56f3

Browse files
authored
Merge pull request #10 from scala-exercises/al-options-fixes
Include the implementation of `maybeItWillReturnSomething`
2 parents f76a77b + f9b0d10 commit f2a56f3

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/main/scala/stdlib/Options.scala

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,15 @@ object Options extends FlatSpec with Matchers with exercise.Section {
2222
emptyValue should be(res1)
2323
}
2424

25-
/** Using `getOrElse` we can provide a default value ("No value") when the optional argument (`None`) does not exist:
25+
/** Let's write a function that may or not give us a string, thus returning `Option[String]`:
26+
*
27+
* {{{
28+
* def maybeItWillReturnSomething(flag: Boolean): Option[String] = {
29+
* if (flag) Some("Found value") else None
30+
* }
31+
* }}}
32+
*
33+
* Using `getOrElse` we can provide a default value ("No value") when the optional argument (`None`) does not exist.
2634
*/
2735
def getOrElseOptions(res0: String, res1: String, res2: String) {
2836
val value1 = maybeItWillReturnSomething(true)

0 commit comments

Comments
 (0)