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 trialbrioz
756 PointsWhy can't you specify a type for the constant areainmeters?
Why does the following not work as well?
let areainmeters: Double = area / 10.765
1 Answer
Edwin Vergara
6,477 Pointslet areainmeters: Double = Double(area) / 10.765
brioz
756 Pointsbrioz
756 PointsI noticed you have to set area as a double, but if your setting the type for areainmeters as Double, why doesn't Xcode infer that the calculation should be a Double?
Edwin Vergara
6,477 PointsEdwin Vergara
6,477 PointsSwift is a type safe language and it encourages you to be clear about the types of values your code can work with. In Swift values are never implicitly converted to another type. If you need to convert a value to a different type, explicitly make an instance of the desired type.