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 trialjoshuawalliy
1,131 PointsI understand how to code but what's the error?
error: swift_lint.swift:15:16: error: '(StringLiteralConvertible) -> $T2' is not identical to 'String' if let n = name ("Snow White"){ ^
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 n = name ("Snow White"){
println("Found")
}
}
2 Answers
Jhoan Arango
14,575 PointsHey Josh:
You are not calling the function.
This is what you are looking for to pass the challenge.
func search(name 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")
}
The challenge wants you to use the if let statement, with a constant named "result", and then call the function with "Doc".
joshuawalliy
1,131 PointsThere are two different teachers.
Jhoan Arango
14,575 PointsWell, there are different. Amit, was the initial teacher for the Swift 1.2 courses, but for Swift 2.0 Pasan took over, because Amit is no longer teaching, he is now in a different position in treehouse.
joshuawalliy
1,131 Pointsjoshuawalliy
1,131 PointsI was looking at the track for the rest of IOS development. I saw that there are teachers. Why?
Jhoan Arango
14,575 PointsJhoan Arango
14,575 PointsWhat do you mean ?