def my_method(*args)
options = args.extract_options!
puts "Arguments: #{args.inspect}"
puts "Options: #{options.inspect}"
end
my_method(1, 2)
# Arguments: [1, 2]
# Options: {}
my_method(1, 2, :a => :b)
# Arguments: [1, 2]
# Options: {:a=>:b}
沒有留言:
張貼留言