Skip to content

Commit 6660729

Browse files
author
Sebastian Harko
committed
break lines
1 parent ef0d291 commit 6660729

File tree

1 file changed

+11
-14
lines changed

1 file changed

+11
-14
lines changed

src/dotty/tools/dotc/reporting/diagnostic/messages.scala

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -515,34 +515,31 @@ object messages {
515515
case class YieldOrDoExpectedInForComprehension()(implicit ctx: Context) extends Message(19) {
516516
val kind = "Syntax"
517517
val msg = hl"${"yield"} or ${"do"} expected"
518-
519-
val code1 = "val numbers = for i <- 1 to 3 yield i"
520-
val code2 = "val numbers = for (i <- 1 to 3) yield i"
521-
val code3 = "for (i <- 1 to 3) println(i)"
522-
val code4 = "for i <- 1 to 3 do println(i) // notice the 'do' keyword"
523-
518+
524519
val explanation =
525-
hl"""When the enumerators in a for comprehension are not placed in parentheses or braces, a ${"do"} or ${"yield"} statement
526-
|is required after the enumerators section of the comprehension.
520+
hl"""When the enumerators in a for comprehension are not placed in parentheses or
521+
|braces, a ${"do"} or ${"yield"} statement is required after the enumerators section
522+
|of the comprehension.
527523
|
528524
|You can save some keystrokes by omitting the parentheses and writing
529525
|
530-
|$code1
526+
|${"val numbers = for i <- 1 to 3 yield i"}
531527
|
532528
| instead of
533529
|
534-
|$code2
530+
|${"val numbers = for (i <- 1 to 3) yield i"}
535531
|
536532
|but the ${"yield"} keyword is still required.
537533
|
538-
|For comprehensions that simply perform a side effect without yielding anything can also be written without parentheses
539-
|but a ${"do"} keyword has to be included. For example,
534+
|For comprehensions that simply perform a side effect without yielding anything
535+
|can also be written without parentheses but a ${"do"} keyword has to be included.
536+
|For example,
540537
|
541-
|$code3
538+
|${"for (i <- 1 to 3) println(i)"}
542539
|
543540
| can be written as
544541
|
545-
|$code4
542+
|${"for i <- 1 to 3 do println(i) // notice the 'do' keyword"}
546543
|
547544
|""".stripMargin
548545
}

0 commit comments

Comments
 (0)