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 trialJohn Conner
950 PointsI am not sure what I am over thinking. But I am pretty sure I have completely
Again, I am not sure what is causing me the most issue. Logic or syntax or [] opposed {} and (). I get what an instance is, data that is passed through the structure/function. The method is the operations performed on the data. an instance method is a type of method used to manipulate a data set to achieve new/different results.
struct Person {
let firstName: String
let lastName: String
func fullName() -> [String] {
}
return "/firstName" + " /lastName"}
}
let fullName = (firstName: "John", lastName: "Conner")
1 Answer
nickyp
2,140 PointsBelow is a working solution:
struct Person {
let firstName: String
let lastName: String
func fullName() -> String {
return firstName + " " + lastName
}
}
The challenge asks you to "Declare a method named fullName() that returns a string containing the personβs full name"
- First, you specified that a method fullName() will return an Array of type String (an Array containing Strings). The challenge asks you to return a String.
- Second, the return statement should be inside the body (code block) of the fullName() method (within {}).
- Third, when you type - return "/firstName" + " /lastName"}, you are trying to use String Interpolation, but in this case it isn't necessary because the firstName and lastName properties are already of type String.
Here are some links that will help you better understand these concepts: Strings and Characters, Code Blocks