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![](https://ecs-static.teamtreehouse.com/assets/views/marketing/shared/community-banner-white-47072046c51352fe6a69f5e691ff5700b28bb11d45197d7bdf066d9ea3f72d0c.webp)
![Pierre-Emmanuel Turcotte](https://secure.gravatar.com/avatar/94888b3a64ba659b17df76396974c069?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Pierre-Emmanuel Turcotte
13,670 PointsWhy no if Let unwrapper to use sendNotice() after chaining ToInt to findApt("101")?
Since the chained function ToInt() also returns an optional, why do we get rid of the if let unwrapper?
1 Answer
![Ezekiel Elin](https://secure.gravatar.com/avatar/e593d7a2fe3f814ec265deedc2a6adce?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Ezekiel Elin
3,839 PointssendNotice()
doesn't return any values. Therefor it doesn't require unwrapping while calling it.
when you use toInt, by using an if let
statement, you are unwrapping the integer and making it non optional. Now that you have unwrapped it, the if statement calls sendNotice()
. Because sendNotice()
is inside the if statement, it only happens if the optional is not nil.
If it was nil, the if statement didn't run, it wouldn't call sendNotice()