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 trialJonathan Hector
5,225 PointsNot working the same way as the video with the recent update
Here's my code and it doesn't work the same way as you see on the video. That's the swift version I have.
Apple Swift version 3.0.2 (swiftlang-800.0.63 clang-800.0.42.1) Target: x86_64-apple-macosx10.9
Any help would be appreciated
struct Person {
let firstName: String
let middleName: String?
let lastName: String
func fullName() -> String {
if middleName == nil {
return firstName + " " + lastName
} else {
return firstName + " " + middleName! + " " + lastName
}
}
let me = Person(firstName: "Jonathan", middleName: nil, lastName: "Hector")
me.fullName()
let airportCodes = ["CDG": "Charles De Gaule"]
let newYorkAirport = airportCodes["JFK"]
1 Answer
luke jones
8,915 PointsHi Jonathan,
I believe you are missing a curly bracket after the line
return firstName + " " + middleName! + " " + lastName
Jonathan Hector
5,225 PointsJonathan Hector
5,225 Pointsthanks really appreciate it.