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, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access