ブロックを処理する関数を書く
def a_method(a = 0)
raise unless block_given?
puts yield(0)
puts yield(a)
b_method(a) { yield(a) + 1 }
rescue
puts "Error (on #{__method__})"
end
def b_method(a)
raise unless block_given?
puts yield(a)
yield(a) + 1
rescue
puts "Error (on #{__method__})"
end
p a_method(1) { |x| x + 1 }
p a_method(1) { |x| x + 5 }
=begin
1
2
3
4
5
6
7
8
=end