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

iOS Object-Oriented Swift Properties Optional Property

andrew park
andrew park
2,733 Points

Both these work on my playground should I use the second celsius = (newValue + 32)/1.8 celsius = newValue

The second didn't work on your challenge but did on my playground !

2 Answers

Victor Naumik
Victor Naumik
2,423 Points

You're setting a temperature.fahrengeit = ... If you simply assign it to celsius - it will be wrong.

The challenge checks for it, and the playground doesn't - cause it doesn't know anything about units of temperature or whatever, just the validity of code.

I mean - your code is valid, but it's wrong physically.

The code is definitely not valid - you should get the error within your playground "Cannot assign to the result of this expression". If you are not then Xcode has probably crashed. Save out and reload, and the error should then show.

A good tip to spot when this has happened (as it has countless times to me throughout this course). Is when the results column stops updating. In your particular example, if you tried to assign a new value to Fahrenheit, you would notice that nothing updates.