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

hi can someone help me with the answer to this maltiple choice question

hi can someone help me the answer to this question

var foo: String? = "bar" var baz = foo?.isEmpty

what is the inferred type of baz?

  1. Bool!

  2. the code will not compile

  3. Bool

  4. Bool?

1 Answer

Hey Jon,

The right answer is 4.Bool?

Why?

Because when you do this foo?.isEmpty you are using Optional Chaining. So it consequently returns an optional value that in this case was a Bool.

Check this link about optional chaining it may help you. example link