/ Published in: Ruby
See also p. 348 ("Invoking a Method") of Pickaxe 2nd edition
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
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:...>