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
Renee Rhodes
10,653 PointsError when calculating error in sq. meters
I get an error "type int does not conform to protocol" with this code:
let height = 12 //In Feet let width = 10 //In Feet
let area = height * width
//1 sq. meter = 1 sq. foot / 10.764 let areaInMeters = area / 10.764
I have compared it side by side to the video and it is identical in every way I can see. I have a screen cap but I can't upload it here.
It works just fine when change it to:
let height = 12.0 //In Feet let width = 10.0 //In Feet
let area = height * width
//1 sq. meter = 1 sq. foot / 10.764 let areaInMeters = area / 10.764
1 Answer
William Li
Courses Plus Student 26,868 PointsHi, Renee Rhodes ,
Someone has provided a pretty detailed answer to a similar question here https://teamtreehouse.com/forum/error-type-int-does-not-conform-to-protocol-floatliteralconvertible-i-had-to-use-120-100
I have compared it side by side to the video and it is identical in every way I can see
Yeah, I totally get what you are talking about, in the video, Amit typed this line let areaInMeters = area / 10.764 and The playground is totally okay with the mixing types. But I'd suggest that you shouldn't get too hung up on this, remember that Swift is a very young language, and Apple is making change and improvement to it very aggressively since Swift's first public release last year, it's entirely possible that Apple implemented some breaking change to Swift' language specs in the newer version of Xcode since this course video was made.