#odersky-programming-in-scala-1ed #scala
where you'd
say "public" in Java, you simply say nothing in Scala. Public is Scala's default access level.
If you want to change selection, open document below and click on "Move attachment"
Classes and Objectsthe class would fail:
val acc = new ChecksumAccumulator
acc.sum = 5 // Won't compile, because sum is private
Note
The way you make members public in Scala is by not explicitly specifying
any access modifier. Put another way, <span>where you'd
say "public" in Java, you simply say nothing in Scala. Public is Scala's default access level.
Now that sum is private, the only code that can access sum is code defined inside the body of the class itself.
Thus, ChecksumAccumulator won't be of much use to anyone unless we define Summary
status | not read | | reprioritisations | |
---|
last reprioritisation on | | | suggested re-reading day | |
---|
started reading on | | | finished reading on | |
---|
Details