Return to Snippet

Revision: 5671
at March 24, 2008 22:41 by cczona


Initial Code
def name(params, hash, *array, &proc );
  puts params.inspect, hash.inspect, array.inspect, proc.inspect
end

name(1, 2=>3, 4=>5, *[6,7,8]) {9} #disambiguate array
puts
name(1, {2=>3, 4=>5}, 6,7,8) {9} #disambiguate hash
puts
name(1, {2=>3, 4=>5}, 6,7,8, &lambda {9}) #called with lambda instead of block
puts
name(1, 2=>3, 4=>5, *[6,7,8], &Proc.new {9}) #or proc instead of block

# 1
# {2=>3, 4=>5}
# [6, 7, 8]
# #<Proc:...>

Initial URL

                                

Initial Description
See also p. 348  ("Invoking a Method") of Pickaxe 2nd edition

Initial Title
order/format of params in method definition

Initial Tags
ruby

Initial Language
Ruby