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 trialoktay asci
Front End Web Development Techdegree Student 1,278 PointsI get an error message when I typ let areaInMeters = area / 10.764
Hi, I get an error message when I type let areaInMeters = area / 10.764
oktay asci
Front End Web Development Techdegree Student 1,278 Points// Playground - noun: a place where people can play
import UIKit
var x = 1 + 2
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
4 Answers
William Li
Courses Plus Student 26,868 PointsOh, right, that one, you have to do this
let areaInMeters = Double(area) / 10.764
Yeah, I know Amit Bijlani wrote it like this let areaInMeters = area / 10.764
during the video and Playground doesn't seem complaining. I don't have a answer as to why, but consider how new the Swift language is, maybe Apple implemented some new changes to the Swift on the newer version of Xcode.
Matthew Litherland
1,752 PointsI suggest this:
let height = 12.0 // Feet
let width = 10.0 // Feet
let area = height * width
let areaInMeters = area / 10.764
But you can also produce the same result using this:
let height = 12 // Feet
let width = 10 // Feet
let area = height * width
let areaInMeters = Double(area) / 10.764
oktay asci
Front End Web Development Techdegree Student 1,278 PointsHi, I have checked again my codes. And I saw that I have wrote 12 instead of writing 12.0 .....
oktay asci
Front End Web Development Techdegree Student 1,278 PointsThanks William for Help.
William Li
Courses Plus Student 26,868 PointsWilliam Li
Courses Plus Student 26,868 Pointscan you post your complete code? thanks.