O'Reilly logo

Learning Jupyter by Dan Toomey

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Named arguments

Scala allows you to specify parameter assignment by name rather than just ordinal position. For example, we can have this code:

def divide(dividend:Int, divisor:Int): Float = 
{ dividend.toFloat / divisor.toFloat }
divide(40, 5)
divide(divisor = 40, dividend = 5)

If we run this in a notebook, we can see the results:

Named arguments

The first call is to divide assigned parameters by position. The second call set them accordingly.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required