Ruby/Statement/while as Modifier

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

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

Текущая версия на 18:00, 13 сентября 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