#classes #scala
You already have seen all the examples using singleton objects where you called Scala's main method.
If you want to change selection, open document below and click on "Move attachment"
Scala Classes & Objects singleton is a class that can have only one instance, i.e., object. You create singleton using the keyword object instead of class keyword. Since you can't instantiate a singleton object, you can't pass parameters to the primary constructor. <span>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 xc: Int, val yc: Int) {
var x: Int = xc
var y: Int = yc
def move(dx: Int, dy: Int) {
Summary
status | not read | | reprioritisations | |
---|
last reprioritisation on | | | suggested re-reading day | |
---|
started reading on | | | finished reading on | |
---|
Details