Do you want BuboFlash to help you learning these things? Or do you want to add or correct something? Click here to log in or create user.



Tags
#odersky-programming-in-scala-1ed #scala
Question
whenever you [...], its result type will definitely be Unit . This is true no matter what the body contains, because the Scala compiler can convert any type to Unit .
Answer
leave off the equals sign before the body of a function

Tags
#odersky-programming-in-scala-1ed #scala
Question
whenever you [...], its result type will definitely be Unit . This is true no matter what the body contains, because the Scala compiler can convert any type to Unit .
Answer
?

Tags
#odersky-programming-in-scala-1ed #scala
Question
whenever you [...], its result type will definitely be Unit . This is true no matter what the body contains, because the Scala compiler can convert any type to Unit .
Answer
leave off the equals sign before the body of a function
If you want to change selection, open document below and click on "Move attachment"

Classes and Objects
hecksumAccumulator { private var sum = 0 def add(b: Byte) { sum += b } def checksum(): Int = ~(sum & 0xFF) + 1 } Listing 4.1 - Final version of class ChecksumAccumulator. One puzzler to watch out for is that <span>whenever you leave off the equals sign before the body of a function, its result type will definitely be Unit. This is true no matter what the body contains, because the Scala compiler can convert any type to Unit. For example, if the last result of a method is a String, but the method's result type is declared to be Unit, the String will be converted to Unit and its value lost. Here's an example:

Summary

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill

Details

No repetitions


Discussion

Do you want to join discussion? Click here to log in or create user.