Hacker News new | ask | show | jobs
by kllrnohj 2950 days ago
Perhaps worth noting that none of that is langauge syntax, it's library syntax. mapOf takes vararg pairs: Pair<K, V>, and then the 'to' operator is an infix function that makes a Pair<K,V>.

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 comments

how can a newly designed language not make lists and maps first class citizens?
So that you can use any map or list implementation without them being second-class citizens, that's why.