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 trialSaadia Fattah
1,939 PointsI don't understand why this says this
We expected the "integer" variable to equal 123, but it was: nil
string = "123"
# YOUR CODE HERE
string = integer.to_i
string = float.to_f
1 Answer
Rogier Nitschelm
iOS Development Techdegree Student 5,461 PointsTake a look at the message. It states that the integer
variable is supposed to equal 123
. But apparently it does not.
The two questions you could ask are:
- Has a variable named integer been declared?
- If yes, have I assigned a value of
123
to it?
string = integer.to_i
Here you are assigning the result of integer.to_i
to a variable named string
. But what I think you want to do is assign the result of string.to_i
to a variable named integer
.
Perhaps:
string = "123"
integer = string.to_i # "123" => 123
?