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 Enumerations and Optionals in Swift Introduction to Optionals Nil Values in Collections

josh hahn
josh hahn
5,926 Points

I have no idea what I am doing wrong here

I have no idea what I am doing wrong here

optionals.swift
let movieDictionary = ["Spectre": ["cast": ["Daniel Craig", "Christoph Waltz", "LÊa Seydoux", "Ralph Fiennes", "Monica Bellucci", "Naomie Harris"]]]

var leadActor: String = ""

// Enter code below

if let movie = movieDictionary["Specter"], let movieCast = movie["cast"]{
    leadActor = movieCast[0]
}

1 Answer

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there! You're either going to love or hate this answer. Your syntax and logic are spot on. You're doing the if let like a pro! So kudos! :thumbsup:

It's your spelling that's a little off. You're getting the movieDictionary for the movie "Specter", but you should be getting it for "Spectre". Note the reversal of the "r" and the "e" in the movie title.

Hope this helps! :sparkles:

josh hahn
josh hahn
5,926 Points

dangit I hate it when I make silly stupid mistakes