Scala – Procedures

  • date 26th April, 2021 |
  • by Prwatech |
  • 0 Comments

A Function, that doesn't return anything can return a Unit that is comparable to void in Java and shows that function doesn't return anything back. The functions which don't return anything in Scala, they are called procedures.

use case 1:

scala> def rect_area(length:Float, breadth:Float) {val area = length*breadth; println(area)}

use case 2:

scala> def circle_area(radius:Float) {val area = 3.14*radius*radius; println(area)}

use case 3:

 

Quick Support

image image