Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
#until loop
counter = 1
until counter == 10
puts counter
counter +=1
end
puts counter
#until loop
i = 0
until i == 6
i+=1
end
puts i
#while loop
counter = 1
while counter <11
puts counter
counter +=1
end
#case example
user_input = $stdin.gets.chomp
user_input.downcase!
case user_input
when 3
puts "£££"
when 2
puts "££"
when 1
puts "£"
end
#Case Example.
current_energy = 3
case current_energy
when 3
puts "Energy is 3"
when 2
puts "Energy is 2"
when 1
puts "Energy is 1"
else
puts "Nil"
end
Advertisements
We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.
AcceptLearn more