开发者

What does a single splat/asterisk in a Ruby argument list mean? [duplicate]

开发者 https://www.devze.com 2023-04-06 20:21 出处:网络
This question already has an answer here: naked asterisk as parameter in method definition: def f(*) 开发者_Python百科(1 answer)
This question already has an answer here: naked asterisk as parameter in method definition: def f(*) 开发者_Python百科 (1 answer) Closed 10 years ago.

I was poking through the Rails 3 ActiveRecord source code today and found a method where the entire parameter list was a single asterisk.

def save(*)

I couldn't find a good description of what this does (though I have some ideas based on what I know about splat arguments).

What does it do, and why would you use it?


It means it can have any number of arguments (including zero) and it discards all those arguments.

0

精彩评论

暂无评论...
验证码 换一张
取 消