Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Ruby Ruby Basics Conditionals Boolean Operators

Couldn't the first if statement in the price method be changed to just quantity > 100? not quantity >= 100??

Since the second if statement runs if the input is 100?

1 Answer

If you are taking about this code:

def price(quantity)
    if quantity >= 100
         price_per_unit = 8
    end
    if quantity >=50 && quantity < 100
        price_per_unit = 9    
    end 
end

The following runs if quantity is less than 100 and greater than or equal to 50 but not equal to 100

 if quantity >=50 && quantity < 100

You can see this @7:55 in the video when a value of 100 is entered and the total is $800

lol nvm, i got it. i dont know what I was thinking. thanks.