4 ms·
First thing I noticed. The map entry syntax: "Foo" to "Bar" Is also nonsensical. What's wrong with ':'?
by foobarbazetc 9y ago
First thing I noticed. The map entry syntax:
"Foo" to "Bar"
Is also nonsensical. What's wrong with ':'?
- ptx 9y agoIt's because to is an infix extension method, whereas : is not a valid identifier name (and so can't be used as the method name) and you can't define arbitrary operators like in C++ and Scala. The to method constructs a Pair object from its arguments, so "Foo" to "Bar" is just a prettier way of writing: Pair("Foo", "Bar") The mapOf function (which is just a normal function) takes a variable number of Pair objects as parameters.