July 2017
Intermediate to advanced
796 pages
18h 55m
English
Sometimes, you would like to make your applications, code modular by avoiding too long and complex methods. Scala provides you this facility to avoid your methods becoming overly large so that you can split them up into several smaller methods.
On the other hand, Java allows you only to have the methods defined at class level. For example, suppose you have the following method definition:
def main_method(xs: List[Int]): Int = { // This is the nested helper/auxiliary method def auxiliary_method(accu: Int, rest: List[Int]): Int = rest match { case Nil => accu case _ => auxiliary_method(accu + rest.head, rest.tail) }}
Now, you can call the nested helper/auxiliary method as follows:
auxiliary_method(0, xs)
Considering the ...
Read now
Unlock full access