O'Reilly logo

Pragmatic Scala by Venkat Subramaniam

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

Implicit Parameters

In Providing Default Values for Parameters you learned about default values for parameters—if you don’t pass an argument for a parameter, Scala will give it a default value. That’s nice; we don’t have to give values that are intuitively obvious or that can be inferred by default. But the default value that’s given is decided by the creator of the function and not the caller. Scala provides an alternative, so the caller can decide what value to send—by default—instead of the function definer deciding that.

Let’s consider an example that will benefit from this feature. With smartphones and mobile devices that we all carry around, we constantly have to connect to different networks: one network at home, another at the office, ...

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