8000 Update Option examples to more modern style · scala/scala3@02f1857 · GitHub
[go: up one dir, main page]

Skip to content

Commit 02f1857

Browse files
committed
Update Option examples to more modern style
1 parent 6735bbe commit 02f1857

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

library/src/scala/Option.scala

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,18 +55,18 @@ object Option {
5555
* `foreach`:
5656
*
5757
* {{{
58-
* val name: Option[String] = request getParameter "name"
59-
* val upper = name map { _.trim } filter { _.length != 0 } map { _.toUpperCase }
60-
* println(upper getOrElse "")
58+
* val name: Option[String] = request.getParameter("name")
59+
* val upper = name.map(_.trim).filter(_.length != 0).map(_.toUpperCase)
60+
* println(upper.getOrElse(""))
6161
* }}}
6262
*
6363
* Note that this is equivalent to {{{
6464
* val upper = for {
65-
* name <- request getParameter "name"
65+
* name <- request.getParameter("name")
6666
* trimmed <- Some(name.trim)
6767
* upper <- Some(trimmed.toUpperCase) if trimmed.length != 0
6868
* } yield upper
69-
* println(upper getOrElse "")
69+
* println(upper.getOrElse(""))
7070
* }}}
7171
*
7272
* Because of how for comprehension works, if $none is returned
@@ -254,7 +254,7 @@ sealed abstract class Option[+A] extends IterableOnce[A] with Product with Seria
254254
* }}}
255255
* This is also equivalent to:
256256
* {{{
257-
* option map f getOrElse ifEmpty
257+
* option.map(f).getOrElse(ifEmpty)
258258
* }}}
259259
* @param ifEmpty the expression to evaluate if empty.
260260
* @param f the function to apply if nonempty.

0 commit comments

Comments
 (0)
0