Accessing a value in a method using *

后端 未结 2 1382
花落未央
花落未央 2021-01-20 13:49

In a method definition, when * is used in the following manner, what does it mean?

def foo(*)
   ...
end

I understand the foll

2条回答
  •  暖寄归人
    2021-01-20 14:34

    It means "take and discard any number of parameters".

    Both definitions are technically the same, but not giving a name to the argument array means you can't access it.

提交回复
热议问题