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 trialBenjamin Tinsley
3,334 PointsWhy wont my solution pass?
I am getting the error Bummer! Make sure your function does not take any parameters and returns a String
which is not very helpful because my function does not take any parameters and it both explicitly and implicitly returns a string.
If I run this in Xcode, it returns the name I give it as expected. Why wont Treehouse? Seems like there is one very specific way to get it to pass and I'm just not seeing what that is.
struct Person {
let firstName: String
let lastName: String
func fullName() -> (String) {
return "\(firstName) \(lastName)"
}
}
let ralph = Person(firstName: "Ralph", lastName: "Harris")
print( ralph.fullName() )
// prints "Ralph Harris"
1 Answer
Jennifer Nordell
Treehouse TeacherHi there! You've put the return type in parentheses which is causing the challenge to fail. If I remove your bottom 2 test lines and then remove the parentheses from (String)
, your code passes.
Take a look:
func fullName() -> String { //note the removal of the parentheses around String
return "\(firstName) \(lastName)"
}
}
Hope this helps!
Benjamin Tinsley
3,334 PointsBenjamin Tinsley
3,334 PointsPerfect, thanks Jennifer. I just did that myself and it worked. Glad you helped!