If you are coming from pure functional background , you would prefer haskel way of function definition like the one below - sqrt1
Single parameter
def sqrt1: Int => Int = value => value * value
where as some guys may like using parenthesis to specify the function parameters.
But both have same functionality. - sqrt2
def sqrt2(value:Int) = value * value
Choose your style!!!!!
More than one parameter
def sumOfSqrt1:(Int,Int) => Int = (x,y) => x*x + y*yIf you define more than one parameters , you must specify the parenthesis separated with by colon (:), but it is not the way we saw in sqrt2
Syntax
<functionName> : (<paramater:Type>,<parameter:Type>) => <return_type>
Other way
def sumOfSqrt2(x:Int,y:Int):Int = x*x + y*yEven you can give function parameters after the equal (=) sign also.
val sumSquare1 = (a: Int,b: Int) => a + b