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
When a singleton object shares the same name with a class, it is called that class's companion object. You must define both the class and its companion object in [where?].
Answer
the same source file

Tags
#odersky-programming-in-scala-1ed #scala
Question
When a singleton object shares the same name with a class, it is called that class's companion object. You must define both the class and its companion object in [where?].
Answer
?

Tags
#odersky-programming-in-scala-1ed #scala
Question
When a singleton object shares the same name with a class, it is called that class's companion object. You must define both the class and its companion object in [where?].
Answer
the same source file
If you want to change selection, open original toplevel document below and click on "Move attachment"

Parent (intermediate) annotation

Open it
When a singleton object shares the same name with a class, it is called that class's companion object. You must define both the class and its companion object in the same source file. The class is called the companion class of the singleton object. A class and its companion object can access each other's private members.

Original toplevel document

Classes and Objects
s like a class definition, except instead of the keyword class you use the keyword object. Listing 4.2 shows an example. The singleton object in this figure is named ChecksumAccumulator, the same name as the class in the previous example. <span>When a singleton object shares the same name with a class, it is called that class's companion object. You must define both the class and its companion object in the same source file. The class is called the companion class of the singleton object. A class and its companion object can access each other's private members. The ChecksumAccumulator singleton object has one method, named calculate, which takes a String and calculates a checksum for the characters in the String. It also has one private field,

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.