Ruby/Statement/while as Modifier

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

Версия от 18:00, 13 сентября 2010; ViGOur (Обсуждение | вклад)
(разн.) ← Предыдущая | Текущая версия (разн.) | Следующая → (разн.)
Перейти к: навигация, поиск

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