Skip to content

Commit 61b9ed6

Browse files
committed
Fix empty exercises
1 parent 0ab51d2 commit 61b9ed6

File tree

2 files changed

+25
-27
lines changed

2 files changed

+25
-27
lines changed

src/main/scala/scalatutorial/sections/LazyEvaluation.scala

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,18 @@ object LazyEvaluation extends ScalaTutorialSection {
209209
* lazy val x = expr
210210
* }}}
211211
*
212+
* = Lazy Vals and Streams =
213+
*
214+
* Using a lazy value for `tail`, `Stream.cons` can be implemented more efficiently:
215+
*
216+
* {{{
217+
* def cons[T](hd: T, tl: => Stream[T]) = new Stream[T] {
218+
* def head = hd
219+
* lazy val tail = tl
220+
* …
221+
* }
222+
* }}}
223+
*
212224
* == Exercise ==
213225
*/
214226
def lazyVal(res0: String): Unit = {
@@ -223,18 +235,4 @@ object LazyEvaluation extends ScalaTutorialSection {
223235
builder.result() shouldBe res0
224236
}
225237

226-
/**
227-
* = Lazy Vals and Streams =
228-
*
229-
* Using a lazy value for `tail`, `Stream.cons` can be implemented more efficiently:
230-
*
231-
* {{{
232-
* def cons[T](hd: T, tl: => Stream[T]) = new Stream[T] {
233-
* def head = hd
234-
* lazy val tail = tl
235-
* …
236-
* }
237-
* }}}
238-
*/
239-
def nothing(): Unit = ()
240238
}

src/main/scala/scalatutorial/sections/StructuringInformation.scala

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -141,19 +141,19 @@ object StructuringInformation extends ScalaTutorialSection {
141141
* the possible case of symbols is fixed. The compiler can leverage this
142142
* knowledge to warn us if we write code that does not handle ''all''
143143
* the cases:
144-
*/
145-
def unexhaustive(): Unit = {
146-
sealed trait Symbol
147-
case class Note(name: String, duration: String, octave: Int) extends Symbol
148-
case class Rest(duration: String) extends Symbol
149-
150-
def nonExhaustiveDuration(symbol: Symbol): String =
151-
symbol match {
152-
case Rest(duration) => duration
153-
}
154-
}
155-
156-
/**
144+
* {{{
145+
* def unexhaustive(): Unit = {
146+
* sealed trait Symbol
147+
* case class Note(name: String, duration: String, octave: Int) extends Symbol
148+
* case class Rest(duration: String) extends Symbol
149+
*
150+
* def nonExhaustiveDuration(symbol: Symbol): String =
151+
* symbol match {
152+
* case Rest(duration) => duration
153+
* }
154+
* }
155+
*}}}
156+
*
157157
* Try to run the above code to see how the compiler informs us that
158158
* we don’t handle all the cases in `nonExhaustiveDuration`.
159159
*

0 commit comments

Comments
 (0)