Surprised Symbol.hashCode hasn't been added yet. Could be useful with collections.
-
-
Replying to @_gsathya
class Div{ [Symbol.hashCode]() {return this.val; } constructor(val) {this.val = val; } } new Set.add(new Div(1)).has(new Div(1)) // true
2 replies 1 retweet 7 likes -
Replying to @_gsathya
IIRC something like this was always an intended extension for post-ES6. Make a proposal!
1 reply 0 retweets 3 likes -
Replying to @littledan
This sounds useful, but OTOH I'll have to do the work of optimizing it in V8
1 reply 0 retweets 6 likes -
Replying to @_gsathya @littledan
Do we really need to make this observable as well?
1 reply 0 retweets 0 likes -
Another possibility is to pass the hash/equals function into the Map/Set constructors, removing change to existing code
1 reply 0 retweets 1 like -
Replying to @littledan @_gsathya
I guess in that case I'd prefer the Symbol.hashCode approach. It's kinda insane from the VMs perspective, but probably better for developers
2 replies 0 retweets 0 likes
Something -- anything -- would be helpful; userland version of this sucks: https://github.com/slightlyoff/cassowary.js/blob/master/src/HashSet.js …
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.
& Web Standards TL; Blink API OWNER
Named PWAs w/
DMs open. Tweets my own; press@google.com for official comms.