Optionals: Gold Challenge Solutions

I think I’m on the right track. I arrived at the correct string. Any more elegant solutions?

For reference, this is the bucketList array of Strings:

0 [“Climb Mt. Everest”]
1 [“Read War and Peace”]
2 [“Go on an Arctic expedition with friends”]
3 [“Scuba dive in the Great Blue Hole”]
4 [“Find a triple rainbow”]

//Page 103 - Optionals: Gold Challenge
let position = bucketList.firstIndex(of: "Go on an 
Arctic expedition with friends") //2

if var newPosition = position {
    newPosition += 2 //4
    print(bucketList[newPosition]) //Find a triple rainbow
}
1 Like