Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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.