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

iOS Swift Functions and Optionals Optionals Review: Functions

Eric Greer
Eric Greer
4,997 Points

Question broken?

The starting code fails to evaluate without edits in the editor on the site. Xcode has no problem evaluating the code, however. It complains about a missing curly brace???

divisible.swift
func isDivisible(#dividend: Int, #divisor: Int) -> Bool {
    if dividend % divisor == 0 {
        return true
    } else {
        return false
    }
}
Eric Greer
Eric Greer
4,997 Points

I'm not sure what was wrong here. I hard-refreshed the page and everything worked fine.

2 Answers

Ryan Schumacher
Ryan Schumacher
1,907 Points

You forgot to finish the question, you need to add a function isNotDivisible which is the opposite of is divisible.

func isNotDivisible(#dividend: Int, #divisor: Int) -> Bool {
    if dividend % divisor == 0 {
      return false
    } else {
        return true
    }
}
Eric Greer
Eric Greer
4,997 Points

It just shows that because I refreshed the page. When I had the content shown in the paste, it was still failing to evaluate. There was some problem with the editor... Nevermind!