#ruby block demo 用{}定义一个block
def test_block
yield #调用 test_block代码块
yield #调用test_block 输出this is a block
end
test_block{ puts "this is a block"} #大括号定义一个block
test_block{puts "this is 2 block"}
#上边的执行顺序
=begin
this is a block
this is a block
this is 2 block
this is 2 block
=end
#ruby block args 给代码快传参
def test2_block
yield("hello");#调用test2_block代码块
end
test2_block do|name|
puts "This args is #{name}"; #this args is hello
end
# test2_blck执行
=begin
This args is hello
=end
if 3>2
puts "max"
end