Welcome to the Treehouse Community
Looking to learn something new?
Why are we putting the "let playlistDetailController" assignment inside of the if let statement?
In the video, when Pasan makes the if let statement, he moves this line of code into the if let statement.
let playlistDetailController = segue.destinationViewController as PlaylistDetailViewController
why did he do this? Does it have to be in there. I tried moving out and placing it before the if statement and the app still ran just fine?
In swift we deal with optionals which means that the data we are dealing with might be or returned " nil " and if it's nil the application could crash. Therefore when using "if let" it makes sure that you receive data before it executes the code block and prevent the application to fail. Hope that helps