ruby - What does a splat operator do when it has no variable name? -


i browsing through camping codebase when saw constructor splat being used this:

class fruit    def initialize(*)   end end 

i tried looking "splat no variable name" on site , google, couldn't find besides info splat being used variable name *some_var, not without it. tried playing around on repl, , tried stuff like:

class fruit    def initialize(*)       puts *   end end  fruit.new('boo') 

but runs error:

(eval):363: (eval):363: compile error (syntaxerror) (eval):360: syntax error, unexpected kend (eval):363: syntax error, unexpected $end, expecting kend 

if question hasn't been asked already, can explain syntax does?

typically splat used specify arguments not used method used corresponding method in superclass. here's example:

class child < parent   def do_something(*)     #     super   end end 

this says, call method in super class, passing parameters given original method.

source: programming ruby 1.9 (dave thomas)


Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

css - Firefox for ubuntu renders wrong colors -