def fibUpTo(max) i1,i2=1,1 #parallel assignment while i1<=max yield i1 i1, i2 =i2,i1+i2 end end fibUpTo(1000){|f| print f," "}
富国沪深
浏览 155回答 1
1回答
拉丁的传说
其实就是一个占位符, 把块的内容部份粘进去, 例如, def test yield end test do puts 'this is a test' end 上面test方法中的yield就是 puts 'this is a test'