4 ms·
While somewhat longer, you do have var map = hashMapOf("a" to 6, "b" to 12) var list = listOf(1, 2, 3) This is still not Java-level verbosity.
by itp 9y ago
While somewhat longer, you do have
var map = hashMapOf("a" to 6, "b" to 12)
var list = listOf(1, 2, 3)
This is still not Java-level verbosity.
- shallot_router 9y agoI like that a lot, but the `to` syntax bugs me. Why not a colon, or Scala's `->`?
- ssijak 9y agoYou type "->" faster and easier then "to"?
- shallot_router 9y agoNo, but it's visually clearer to me at a glance. It feels weird using letters, let alone full English words, to describe a mapping or anything else that I think a symbol is more suited for. To me it would feel like assigning a variable with: a equals 6 n equals "A" Just feels icky, somehow. Again, that wouldn't dissuade me from using the language whatsoever. It's only a minor irritation.
- mike_hearn 9y agoBecause "to" isn't actually syntax at all. It's an infix function that creates a Pair. You can alt-click it in the IDE to go to the definition.
- shallot_router 9y ago`->` in Scala is also just a method, but I think it's fair to call such things syntax even if they're not true "baked-in" language syntax.