#classes #scala
Since you can't instantiate a singleton object, you can't pass parameters to the primary constructor.
If you want to change selection, open document below and click on "Move attachment"
Scala Classes & Objectsnted than Java because in Scala we cannot have static members. Instead, Scala has singleton objects. A singleton is a class that can have only one instance, i.e., object. You create singleton using the keyword object instead of class keyword. <span>Since you can't instantiate a singleton object, you can't pass parameters to the primary constructor. You already have seen all the examples using singleton objects where you called Scala's main method. Following is the same example of showing singleton:
import java.io._
class Point(val Summary
status | not read | | reprioritisations | |
---|
last reprioritisation on | | | suggested re-reading day | |
---|
started reading on | | | finished reading on | |
---|
Details