Hacker News new | past | comments | ask | show | jobs | submit login

It'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.



Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: