Ruby/Statement/while as Modifier

Материал из Wiki.crossplatform.ru

(Различия между версиями)
Перейти к: навигация, поиск

Версия 17:10, 26 мая 2010

like if, you can use while as a statement modifier, at the end of a statement

cash = 100_000.00
sum = 0
cash += 1.00 + sum while cash < 1_000_000.00 # underscores ignored



Use while as a Loop Modifier

value = 0
 
value += 1 while value < 100
 
puts value