@@ -155,7 +155,7 @@ object ClassesVsCaseClasses extends ScalaTutorialSection {
155155 * }
156156 *
157157 * // toString redefinition to return the value of an instance instead of its memory addres
158- * override def toString = s"Note($name, $duration, $octave)"
158+ * override def toString = s"Note($name,$duration,$octave)"
159159 *
160160 * // Create a copy of a case class, with potentially modified field values
161161 * def copy(name: String = name, duration: String = duration, octave: Int = octave): Note =
@@ -170,12 +170,19 @@ object ClassesVsCaseClasses extends ScalaTutorialSection {
170170 * new Note(name, duration, octave)
171171 *
172172 * // Extractor for pattern matching
173- * def unapply(note: Note): Option[(String, String, Int)) =
173+ * def unapply(note: Note): Option[(String, String, Int)] =
174174 * if (note eq null) None
175175 * else Some((note.name, note.duration, note.octave))
176176 *
177177 * }
178178 * }}}
179179 */
180- def nothing (): Unit = ()
180+ def encoding (res0 : String , res1 : Boolean , res2 : String ): Unit = {
181+ val c3 = Note (" C" , " Quarter" , 3 )
182+ c3.toString shouldBe res0
183+ val d = Note (" D" , " Quarter" , 3 )
184+ c3.equals(d) shouldBe res1
185+ val c4 = c3.copy(octave = 4 )
186+ c4.toString shouldBe res2
187+ }
181188}
0 commit comments