method parameters in Scala is that they
are val s, not var s.
If you want to change selection, open document below and click on "Move attachment"
Classes and Objects e ChecksumAccumulator now has two methods, add and checksum, both of which exhibit the basic form of a
function definition, shown in Figure 2.1 here.
Any parameters to a method can be used inside the method. One
important characteristic of <span>method parameters in Scala is that they
are vals, not vars.[1]
If you attempt to reassign a parameter inside a method in Scala, therefore, it won't compile:
def add(b: Byte): Unit = {
b = 1 // This won't compile, because b is a val
Summary
status
not read
reprioritisations
last reprioritisation on
suggested re-reading day
started reading on
finished reading on
Details
Discussion
Do you want to join discussion? Click here to log in or create user.