4 ms·
I still refer to the * operator as “splat” after a presentation I saw him give in London in 2007. _why is most definitely gone but not forgotten.
by Lio 2y ago
I still refer to the * operator as “splat” after a presentation I saw him give in London in 2007.
_why is most definitely gone but not forgotten.
- riffraff 2y agoI thought splat was actually the "official" usage these days, tho I think some people call it spread
- byroot 2y agoIt is yes [0]. > You can turn an Array into an argument list with * (or splat) operator > You can turn a Hash into keyword arguments with the * (keyword splat) operator: It's also named spat across the MRI codebase, e.g. `VM_CALL_ARGS_SPLAT` etc. [0] https://docs.ruby-lang.org/en/master/syntax/calling_methods_rdoc.html#label-Unpacking+Positional+Arguments https://docs.ruby-lang.org/en/master/syntax/calling_methods_...
- dragonwriter 2y agosplat is the official name in Ruby, spread comes from the similar JS construct (obviously, lots of people using Ruby also use JS, so its natural for terminology from one context to sometimes get applied to similar concepts in the other even where it isn’t official.)
- Etheryte 2y agoIt's called spread in Javascript [0], where the keyword is `...`. [0] https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_syntax https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...