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 trialKARTHIK MENON
382 PointsUnable to assign instance of a person to "somePerson". Please help.
Please find my code below:
protocol UserType { var name: String { get } var age: Int { get set } }
struct Person: UserType { var name: String var age: Int } let person = Person(name:"somePerson") person.name
protocol UserType {
var name: String { get }
var age: Int { get set }
}
struct Person: UserType {
var name: String
var age: Int
}
let person = Person(name:"somePerson")
person.name
1 Answer
Alejandro Machado
16,091 PointsDo you have the latest version of Xcode (7.2 as of this writing) installed? The error message I get when I try to run this is much more descriptive:
Missing argument for parameter "age" in call
When you defined the Struct person
, a constructor was automatically created for you with both name
and age
. What you need to do is simply:
let person = Person(name: "somePerson", age: 25)
person.name