How does Scala’s apply() method magic work?

I don’t think there’s anything deeper going on than what you have originally said: it’s just syntactic sugar whereby the compiler converts f(a) into f.apply(a) as a special syntax case.

This might seem like a specific rule, but only a few of these (for example, with update) allows for DSL-like constructs and libraries.

Leave a Comment