Ruby Programming Tutorial - Lesson 10 - Loops in Ruby :: Until Loop

Words
82
Reading
1 min
9y
Listen to this post
~1 min

ruby.jpg

This article ..
We are going to learn about Until loop.

Sell burgers, each burger you sell you earn 1$ ... reach your 100$ target
once you reach your target display a message .. of target achievement
# Total Burgers need to sell ? 

$burgers_to_be = $richness_target / $burger_price

begin 
    puts "I need to sell more Burgers :) .. "
    $burgers_balance += $burger_price
    $current_sale = $burgers_balance / $burger_price
    puts "Burger #$current_sale is Sold !! "
    puts "Earned #$burger_price$ "

end until $burgers_balance >= $richness_target


puts "WOW I Sold #$burgers_to_be Burgers "

Here is graphic example..

Here is another example of until loop..
This loop becomes an endless loop.. so you need to hit CTRL + C
to break the loop


# Tell a girl, she cannot be my life partner until she has these three properties 

not_rubyprogrammer          = true
not_rich                    = true
not_beautifull              = true



until !(not_rubyprogrammer && not_rich && not_beautifull)
    puts "No You cannot become my life partner .."
end 

Capture.JPG

Pray for me that i get a good, lady in my life :D thanks

Ruby Programming Tutorial - Lesson 10 - Loops in Ruby :: Until Loop | Ecency