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 trialniloufarsedarati
Courses Plus Student 17,665 PointsWhat's the problem with my sqrt() in ruby math challenge ?
I'm using the sqrt method but still have a problem :-|
@pi = nil
@e = nil
@sqrt = nil
module Math
Math::PI = @pi
Math::E = @e
Math.sqrt(9) = @sqrt
end
1 Answer
Nejc Vukovic
Full Stack JavaScript Techdegree Graduate 51,574 PointsHi.
Well your error is this line:
Math.sqrt(9) = @sqrt //this is not correct because this means you are setting the value to Math.sqrt(9) to the value of @sqrt
Just swap this line and your code should look like this:
@pi = nil
@e = nil
@sqrt = nil
module Math
Math::PI = @pi
Math::E = @e
end
@sqrt = Math.sqrt(9)
Be careful - In programming when you declare a variable the variable is passed the value thats on the right side of =
Hope this helped.
niloufarsedarati
Courses Plus Student 17,665 Pointsniloufarsedarati
Courses Plus Student 17,665 PointsHi , I did this inside the module and I got error. Thank you for your quick response :)
Nejc Vukovic
Full Stack JavaScript Techdegree Graduate 51,574 PointsNejc Vukovic
Full Stack JavaScript Techdegree Graduate 51,574 PointsWelcome :)
Melvin Pacheco
18,880 PointsMelvin Pacheco
18,880 PointsAwesome!