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!

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

iOS Swift 2.0 Functions Function Parameters Returning Complex Values

2,964 Points

Binary 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

Looks 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?

1 Answer

2,964 Points

Thanks Jimi,

I fixed it. You were right, my calculateArea function didn't have a return value.

No problem!