val map = mapOf("firstName" to "John", "lastName" to "Doe")
The above seems a really strange decision for a "new" language - why would you not just use the most common structure, being JSON?
val map = mapOf("firstName" to "John", "lastName" to "Doe")
The above seems a really strange decision for a "new" language - why would you not just use the most common structure, being JSON?
So you could trivially do your own listOf or mapOf that creates whatever data structure you want, whereas languages with special syntax for this tend to hardcode the result of it. That's a valid choice, sure, but just that there are tradeoffs here rather than it being obviously better one way or the other.
[1]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/...
I've been told that it's because "how would it know which specific sequence and map class you want", but it already has Seq() and Map() which give you the default immutable sequence and map classes, so obviously a literal syntax would give you the same one.