test.rb
| 1 |
class SandBox |
|---|---|
| 2 |
def abc(*args) |
| 3 |
yield(*args)
|
| 4 |
end
|
| 5 |
define_method :xyz do |
| 6 |
|*args, &block| |
| 7 |
puts 'About to call the block:'
|
| 8 |
block.call(*args) |
| 9 |
end
|
| 10 |
end
|
| 11 |
puts 'SandBox.new.abc:'
|
| 12 |
SandBox.new.abc(1,2,3){|*args| p args} # => [1, 2, 3] |
| 13 |
puts 'SandBox.new.xyz:'
|
| 14 |
SandBox.new.xyz(1,2,3){|*args| p args} # => [1, 2, 3] |