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 Swift 2.0 Basics Swift Types Mixed Types

Finally, we need to indicate whether the book is available in our store. Declare a variable named isAvailable and assign

thanks

types.swift
// Enter your code below
let title = "A Dance with Dragons"
var rating = 7.5
var boolean isAvailable = 0

1 Answer

Jason Anders
MOD
Jason Anders
Treehouse Moderator 145,858 Points

Hey Harrison,

You've got a couple things going wrong here.

  • First, you've seemed to have injected a bit of Objective-C into the last line of code. In Swift, you don't need to declare type. So, you don't need to have "boolean" in the declaration.

  • Second, with some exceptions (beyond the scope of this question), boolean values can only be "true" or "false", and you are assigning 0.

If you fix those up, you're good to go. Good job. :)

var isAvailable = false

:dizzy:

Thanks Jason, but why do I assign isAvailable to false instead of true

Jason Anders
Jason Anders
Treehouse Moderator 145,858 Points

Hi Harrison,

You know, when I was checking the quiz/code for your post, I was just paying attention to what the challenge was asking for. But then a few days ago, someone also pointed this out. You can read it in this forum post. As Pasan replied, this was an error in the challenge, but as Greg points out, both are fine as the value is stored in a variable and therefore changeable.

Good catch though! :)