Variable Arguments
*args collects extra arguments and **opts collects keywords.
Example
def info(first, *rest, **opts)
"#{first} #{rest} #{opts}"
end
puts info(1, 2, 3, a: 4)
puts [1, 2].push(*[3, 4]).inspectResult
1 [2, 3] {:a=>4}
[1, 2, 3, 4]Exercise
Collect keywords.
def f(opts); end
Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.