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 trialTERRELL TINSLEY
2,964 PointsBinary operator error
let area = calculateArea(length, width: width)
var price: Int
switch carpetColor {
case "gray": price = area * 1
case "tan": price = area * 2
case "blue": price = area * 4
default: price = 0
}
return price
}
carpetCostCalculator(length: 10, width: 20)
I get an error on the switch statement that says, "Binary operator " " cannot be applied to operands of type () and Int.
How can I fix this. Thanks
1 Answer
TERRELL TINSLEY
2,964 PointsThanks Jimi,
I fixed it. You were right, my calculateArea function didn't have a return value.
Jimi Jordan
11,877 PointsNo problem!
Jimi Jordan
11,877 PointsJimi Jordan
11,877 PointsLooks ok to me, except where is carpetColor declared?... but either way it must be something your calculateArea function is returning... could you post that as well?