From 9c5f115fb16708cd01f192f4e3344b409f6ab304 Mon Sep 17 00:00:00 2001 From: Emma Burrows Date: Thu, 31 May 2018 21:09:00 +0100 Subject: [PATCH 1/2] Clarify the purpose of getOrElse --- src/main/scala/stdlib/Options.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/scala/stdlib/Options.scala b/src/main/scala/stdlib/Options.scala index 44643c28..98cc3a0b 100644 --- a/src/main/scala/stdlib/Options.scala +++ b/src/main/scala/stdlib/Options.scala @@ -35,7 +35,7 @@ object Options extends FlatSpec with Matchers with org.scalaexercises.definition * } * }}} * - * Using `getOrElse` we can provide a default value ("No value") when the optional argument (`None`) does not exist: + * Using `getOrElse`, we can extract the value if the `Option[A]` is a `Some[A]`, and provide a default value ("No value") when the optional argument (`None`) does not exist: */ def getOrElseOptions(res0: String, res1: String, res2: String) { val value1 = maybeItWillReturnSomething(true) From c068be16041a1a0b24f0cdd53d41ce7bd9e16b81 Mon Sep 17 00:00:00 2001 From: Emma Burrows Date: Thu, 7 Jun 2018 19:34:19 +0100 Subject: [PATCH 2/2] Split the `getOrElse` explanation into two sentences for clarity. --- src/main/scala/stdlib/Options.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/scala/stdlib/Options.scala b/src/main/scala/stdlib/Options.scala index 98cc3a0b..d5d1a1d4 100644 --- a/src/main/scala/stdlib/Options.scala +++ b/src/main/scala/stdlib/Options.scala @@ -35,7 +35,7 @@ object Options extends FlatSpec with Matchers with org.scalaexercises.definition * } * }}} * - * Using `getOrElse`, we can extract the value if the `Option[A]` is a `Some[A]`, and provide a default value ("No value") when the optional argument (`None`) does not exist: + * Using `getOrElse`, we can extract the value if it exists, or return a provided default value. If we have a `Some(x)` we return `x`, and for `None` we return the default value. */ def getOrElseOptions(res0: String, res1: String, res2: String) { val value1 = maybeItWillReturnSomething(true)