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 Operators and Control Structures Ruby Control Structures If challenge!

Set a variable called "too_fast" to "true" if "car_speed" is greater than "speed_limit". What does it want?

The question says that i must create a variable if the condition is true.

Would i say:

car_speed = 65 speed_limit = 60

if car_speed > speed_limit too_fast = true end

ruby.rb
car_speed = 65
speed_limit = 60



if car_speed > speed_limit

end
samuel gustave
samuel gustave
7,341 Points

Hi, You want to create and set the variable named too_fast. In Ruby, you create a variable like this : too_fast = false // it is created and assigned (or set) at the same time so car_speed = 65 speed_limit = 60 too_fast = false if car_speed > speed_limit
too_fast = true end

2 Answers

Taylor Boudreau
Taylor Boudreau
7,285 Points

Hi there Matthew,

It looks like you're on the right track, it's just hard to tell with the formatting shown there. The answer I had success with is the following:

car_speed = 65
speed_limit = 60

if car_speed > speed_limit
  too_fast = true
end

Hope this helps!

Taylor

This is what my first attempt was.

I've tried everything imaginable, and it continues to tell me that the too_fast variable was not set, when it clearly was. Over and over and over. It's incredibly frustrating.

samuel gustave
samuel gustave
7,341 Points

Hi Jeremy ! In Ruby you declare a variable by assigning (or setting) a value to it. That's the way Ruby knows what kind of variable it is (integer, float, boolean, or string). So if you say : if car_speed > speed_limit too_fast = true # setting too_fast variable to true end