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)
![Adrien Yvon](https://secure.gravatar.com/avatar/e10a1daf67b2112178cffae77c79d7d2?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Adrien Yvon
3,079 PointsIs "Else" necessary in the function?
Hi I was wondering the utility of else in the function, I didn't use it and it worked pretty good.
Here's the code :
func isDivisible (Number1 number1: Int, Number2 number2: Int) -> Bool? {
if number1 % number2 == 0 {
return true }
return nil
}
Thank you !
2 Answers
![Adrien Yvon](https://secure.gravatar.com/avatar/e10a1daf67b2112178cffae77c79d7d2?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Adrien Yvon
3,079 PointsHi Richard thank you for the explanation. I think I got it.
![Richard Lu](https://uploads.teamtreehouse.com/production/profile-photos/789132/micro_10866065_10153022614827378_7886608831407388442_o.jpg)
Richard Lu
20,185 PointsHi Adrien,
In your case, else is never needed because if that if statement is true, then the outer return statement is never reached. If you'd like to experiment, try this out.
func testFunction(condition: Bool) {
if condition {
print("hey it's true!")
return
}
print("hey it's not true") // this line never gets touched
}
testFunction(true) // prints "hey it's true!"
Best of luck and Happy Coding! :)