Re:Better Know a Ruby Thing: Singleton Classes
by riffraff on Saturday February 01, 2025 @03:27AM
(#42896813)
I thought splat was actually the "official" usage these days, tho I think some people call it spread
[ Parent
| on HN ]
Re:Better Know a Ruby Thing: Singleton Classes
by byroot on Saturday February 01, 2025 @05:10AM
(#42897319)
It 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_...
Re:Better Know a Ruby Thing: Singleton Classes
by dragonwriter on Saturday February 01, 2025 @05:12AM
(#42897326)
splat 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.)
Re:Better Know a Ruby Thing: Singleton Classes
by Etheryte on Saturday February 01, 2025 @08:35AM
(#42898178)
It's called spread in Javascript [0], where the keyword is `...`.
[0] https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...