What does the * symbol do near a function argument and how to use that in others scenarios?
Posted
by
user502052
on Stack Overflow
See other posts from Stack Overflow
or by user502052
Published on 2011-03-09T23:20:06Z
Indexed on
2011/03/10
0:10 UTC
Read the original article
Hit count: 375
I am using Ruby on Rails 3 and I would like to know what means the presence of a *
simbol near a function argument and to understand its usages in others scenarios.
Example scenario (this method was from the Ruby on Rails 3 framework:
def find(*args)
return to_a.find { |*block_args| yield(*block_args) } if block_given?
options = args.extract_options!
if options.present?
apply_finder_options(options).find(*args)
else
case args.first
when :first, :last, :all
send(args.first)
else
find_with_ids(*args)
end
end
end
© Stack Overflow or respective owner