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 trialAlex Parkman
Courses Plus Student 1,659 PointsHelp Please?
Need help with this one, it is saying their is a problem with the if let statement regarding the isNotDivisible part. Says it needs to be of Optional Type but i have not specified that anywhere so not sure why it is saying that?
cheers
func isDivisible(#dividend: Int, #divisor: Int) -> Bool {
if dividend % divisor == 0 {
return true
} else {
return false
}
}
func isNotDivisible (#dividend: Int, #divisor: Int) -> Bool {
if dividend % divisor == 0 {
return true
} else {
return false
}
}
if let result = isNotDivisible(dividend: 11, divisor: 3) {
println("Divisible")
} else {
println("Not Divisible")
}
1 Answer
Meek D
3,457 PointsI think you should put the println() statement within the function. Hope that helps ..
func isDivisible(#dividend: Int, #divisor: Int) -> Bool {
if dividend % divisor == 0 {
return true
} else {
return false
}
}
func isNotDivisible (#dividend: Int, #divisor: Int) -> Bool {
if dividend % divisor == 0 {
println("Divisible")
return true
} else {
println("Not Divisible")
return false
}
}
let result = isNotDivisible(dividend: 12, divisor: 3)