5 ms·
Interesting. I didn't know about the 'do' keyword or the repetition bit with {x,y} returning {x: x, y: y}. Pretty cool!
by hasenj 16y ago
Interesting. I didn't know about the 'do' keyword or the repetition bit with {x,y} returning {x: x, y: y}. Pretty cool!
- tomstuart 16y agoThe {x,y} rvalue syntax isn't in the CoffeeScript documentation. This is the first place I've seen it.
- grayrest 16y agoIt was but it got dropped in the doc update for 0.4 or thereabouts. I was hoping he'd take it out for a while because it complicates the disambiguation of braceless object literals but it seems most people like it, so meh.
- tomstuart 16y agoIt's a bit weird that it breaks alpha equivalence (i.e. you expect your program's semantics to be invariant under local variable renaming) but I can see why people like it. It's certainly compact and idiomatic, and there's a nice (albeit superficial) symmetry with destructuring assignment.