3 ms·
Ruby has some of these, too, thanks to its Perl heritage. puts "It worked!" unless error i = 0; puts "Item: #{i+=1}" while i < 5 Unfortunately foreach
by yellowapple 6y ago
Ruby has some of these, too, thanks to its Perl heritage.
puts "It worked!" unless error
i = 0; puts "Item: #{i+=1}" while i < 5
Unfortunately foreach didn't survive, but thankfully arrays have methods to achieve similar concision:
items.each {|i| puts "Item: #{i}"}