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 Exercise: isDivisible function

Preview pane on right does not show {Some value} for optionals but my code still works. Do I have an option turned off?


At 3:40 in Amit's video, the preview pane on the right displays {Some true}. I understand this is because the function is returning a Bool optional. However, while doing this lesson, I noticed that my preview pane was only displaying true, and not {Some true}.

I verified my solution looks the same as Amit's (except some variables named differently) . My code works, and returns true or nil, as Amit's code does.

All of this leads me to believe that there is an option or setting somewhere in Xcode to change the display of returned optionals in the preview pane. Or maybe I have a version of Xcode that is newer than the one used to make the video, and my version doesn't display {Some value}.

Does anybody know if there is an option or setting for this, or if I am doing something wrong? I really would like to see the display as {Some value} as I find it very useful.

I am running Xcode version 6.3.2 (6D2105). Code as follows:

import UIKit

func divide(#first:Int, #second:Int) -> Bool? {
    if first % second == 0 {
        return true
    return nil

if let result = divide(first: 10,second: 10) {
} else {

1 Answer

Different versions of Xcode certainly do have slight differences in how playgrounds show 'warnings' about optionals, among other things. Swift and playgrounds are both new toys, and they're trying to get it right. As for a setting, I'm not seeing anything obvious in the preferences for how the output is displayed in playgrounds.

Thanks Dan,

Thanks for the reply. I'll just move on with the course for now and assume that I'm not doing anything out of the ordinary to make {Some value} not appear.

Thanks again.