level 6
浮云半仙
楼主
module Kernel
def forfor(proc1,proc2,proc3) #实在想不出叫什么名字了就叫forfor了
proc1.call
loop do
proc3.call
break if (proc2.call) == false
yield if (proc2.call) == true
end
end
end
#例子 可以嵌套哟
$times = 0
forfor(Proc.new{$a = 0},Proc.new{$a < 5},Proc.new{$a += 1}) do
forfor(Proc.new{$b= 0},Proc.new{$b < 4},Proc.new{$b += 1}) do
$times += 1
end
end
p $times # 12
2014年04月20日 03点04分
1
def forfor(proc1,proc2,proc3) #实在想不出叫什么名字了就叫forfor了
proc1.call
loop do
proc3.call
break if (proc2.call) == false
yield if (proc2.call) == true
end
end
end
#例子 可以嵌套哟
$times = 0
forfor(Proc.new{$a = 0},Proc.new{$a < 5},Proc.new{$a += 1}) do
forfor(Proc.new{$b= 0},Proc.new{$b < 4},Proc.new{$b += 1}) do
$times += 1
end
end
p $times # 12