i heard scala contains feature called named , default arguments don't know such parameters or how use them.
can explain usage?
some special functions call type in scala
named arguments:
named arguments allow pass arguments function in different order.for example:
def speed(distance: float, time: float): float = distance / time
and can used this:
speed(distance = 100, time = 10)
or
speed(time = 10, distance = 100)
default arguments:
scala lets specify default values function parameters. example:
def printtime(out: java.io.printstream = console.out) = out.println("time = "+ system.currenttimemillis())
then can call printtime without giving output stream this:
printtime()
repeated arguments:
scala allows indicate last parameter function may repeat. example:
def echo(args: string*) = (arg <- args) println(arg)
then can use this:
echo() echo("one") echo("hello", "world!")
Comments
Post a Comment