>quantify=->number{casenumberwhen1'one'when2'acouple'e...。"/>
Ruby 有 if、case 和 while 表达式,它们都以通常的方式工作: >> if 2 < 3 'less' else 'more' end => "less" >> quantify = -> number { case number when 1 'one' when 2 'a couple' else 'many' end } => #<Proc (lambda)> >> quantify.call(2) => "a couple" >> quantify.call(10) => "many" >> x = 1 => 1 >> while x < 1000 x = x * 2 end => nil >> x => 1024