欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

ruby中的循環(huán)語(yǔ)句總結(jié)

 更新時(shí)間:2015年05月26日 09:32:07   投稿:junjie  
這篇文章主要介紹了ruby中的循環(huán)語(yǔ)句總結(jié),本文總結(jié)了Ruby中常用的一些循環(huán)語(yǔ)法,需要的朋友可以參考下

while(當(dāng)…) 循環(huán)

 

 

while 條件

語(yǔ)句1; 語(yǔ)句2 ; 語(yǔ)句…

end

單行 while 循環(huán)

( 語(yǔ)句1; 語(yǔ)句2 ; 語(yǔ)句… ) while 條件

until(直到…) 循環(huán)

until 條件 = while not (條件)

for…in 循環(huán)

 

 

for 變量 in 對(duì)象

語(yǔ)句1; 語(yǔ)句2 ; 語(yǔ)句…

end

break

跳出當(dāng)層循環(huán)

next

忽略本次循環(huán)的剩余部分,開(kāi)始下一次的循環(huán)

redo

重新開(kāi)始循環(huán),還是從這一次開(kāi)始

retry

重頭開(kāi)始這個(gè)循環(huán)體

times

3.times { print "Hi!" } #Hi!Hi!Hi!

upto

1.upto(9) {|i| print i if i<7 } #123456

downto

9.downto(1){|i| print i if i<7 } #654321

each

(1..9).each {|i| print i if i<7} #123456

step

0.step(11,3) {|i| print i } #0369

相關(guān)文章

最新評(píng)論