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 What is an Optional?

kamal bains
seal-mask
.a{fill-rule:evenodd;}techdegree
kamal bains
iOS Development Techdegree Student 1,522 Points

What is wrong with this code? It keeps asking me if I've used println() once and I have.

I'm not sure what this wants me to fix.

search.swift
func search(#name: String) -> String? {
    let names = ["Doc","Grumpy","Happy","Sleepy","Bashful","Sneezy","Dopey"]
    for n in names {
        if n == name {
            return n
        }

    }
    return nil

     if let result = search(name:"Doc")  {
    println("Found")
    }

}

2 Answers

Jhoan Arango
Jhoan Arango
14,575 Points

Hello kamal bains:

You are very very close to the answer ! I can give you the answer or I can just give you a hint of what to do, and perhaps you will figure it out on your own, and if you still don’t understand, then I can give you a better explanation.

Here is the hint: Closing bracket ;)

Good luck, please let me know if it helped you figure it out.

Kamal,

Let us know if you understand the hint that Jhoan gave you. Your code is correct, but its placement is off.

Jhoan Arango
Jhoan Arango
14,575 Points

Hey Aaron Ackerman How are you ? is there any way I can contact you through e-mail ? Would like to ask you some questions... I see you have lot of experience, and was wondering if you can help me with something.

my e-mail is jhoannarango@msn.com