4 ms·
The syntax for instantiating Maps is really ham handed. An array of arrays of key value pairs. I get it. I just wish there was a better syntax. We need Map lite
by Waterluvian 8y ago
The syntax for instantiating Maps is really ham handed. An array of arrays of key value pairs. I get it. I just wish there was a better syntax. We need Map literals and for that I think we need another type of brace character.
I just want Python's dict everywhere. :)
- james-mcelwain 8y agoIf you're ok with string keys, you can always do `new Map(Object.entries(obj))`. Alternatively, just implement the `iterable` interface on your custom data type. Literals are nice sugar, but it hardly seems "ham handed".
- Waterluvian 8y agoEverything is sugar. The right sweetness makes the language.
- deleted 8y ago[deleted]
- anonytrary 8y agoOr they could have just made {[myObject]: myValue} "just work" as opposed to doing this crap: {"[object Object]": myValue} Lua tables are really simple and let you use references as keys.
- always_good 8y agoEh, special-casing specific syntax over regular objects would be a nightmare.