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
Jabran Shakil
2,734 PointsHelp with Challenge Number 3 on Type for Swift iOS
Every time I try to add the code
let price: = 9.99
it doesn't work. I have the previous code from the step before, I've tried every possible combination and it's not letting me proceed to the next step. Any help would be greatly appreciated, thank you.
2 Answers
Stone Preston
42,016 Pointsthat is not the correct way to assign a value to a constant with an inferred type.
to assign a value to a constant with an inferred type write the let keyword, followed by the name of the constant, followed by an equal sign, followed by the value you wish the constant to have
let someConstant = "some value"
you need to remove the colon:
let price = 9.99
the constant above will have an inferred type of Double.
you would use the colon if you wanted to provide an explicit type for the constant, however its perfectly fine to let Swift infer the type
let price: Double = 9.99
see the Swift eBook for more information on creating constants and variables
Jabran Shakil
2,734 PointsAh!!!! Thank you man! I appreciate it, that was frustrating. I understood it now! Cheers and Happy New Year!
Stone Preston
42,016 Pointsno problem