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 trialAdrian Yeow
13,866 PointsBoolean
My question is this. i don't understand this concept.
if let result = isDivisible(dividend: 15, divisor: 14) { println("Divisible") } else { println("Indivisible") }
The else statement "Indivisible" will be printed on the screen. However if we look closely the function isDivisible(dividend: 15, divisor: 4) should evaluate to false or nil. if it is false or nil, the constant result would be evaluated to false and the following code shouldn't be executed.
1 Answer
Jonas Kristensen
2,738 Pointsfunc isNotDivisible(#dividend: Int, #divisor: Int) -> Bool { if dividend % divisor == 1 { return true } else { return false } }