1
votes

I understand that map("key") is possible because Map implements Function1. But how does map("key") = "value" translate to map.update("key", "value")? I don't see a = function defined anywhere in Map or its parent interfaces

1

1 Answers

3
votes

This translation is simply implemented as a rule in the Scala compiler. See the Scala Language Specification:

An assignment f(args) = e with a function application to the left of the ‘=’ operator is interpreted as f.update(args, e), i.e. the invocation of an update function defined by f.