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 trialCorey Dutson
Courses Plus Student 3,193 PointsYou say the property should be "Fahrenheit" but I then get an error saying I need to make a property called "fahrenheit"
I'm pretty sure this is more of a re-jigging of the question to say fahrenheit
instead of "Fahrenheit"
class Temperature {
var celsius: Float = 0.0
var Fahrenheit: Float {
return (celsius * 1.8) + 32
}
}
2 Answers
kjvswift93
13,515 PointsCorey- You have it exactly right except for the single mistake you yourself figured out. In swift, the custom is to declare a variable or constant name using lowercase (at least for the first word), and classes, structs, enums, and protocols using uppercase. That was all that the compiler here in the challenge didn't like. So, the answer would be
class Temperature {
var celsius: Float = 0.0
var fahrenheit: Float {
return (celsius * 1.8) + 32
}
}
Lukas Smith
4,026 PointsChange on var Fahrenheit: Float
Corey Dutson
Courses Plus Student 3,193 PointsYeah I know it had to be a Float, that was not, however, the error the compiler was giving me. It wanted me to make the property name fahrenheit
instead of Fahrenheit
Once I changed it to the lower case version, it then gave me the Double/Float error, which was a non-issue to fix.
Update: changed Double to Float to better illustrate the issue, and not complicate it by layering errors