3 ms·
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 fun
by kllrnohj 8y 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.
- singularity2001 8y agohow can a newly designed language not make lists and maps first class citizens?
- kllrnohj 8y agoSo that you can use any map or list implementation without them being second-class citizens, that's why.