swift - What is the proper syntax for accessing a struct variable? -
what proper syntax access fellow member struct variable? i'm trying this:
struct 1 { var name:string = "ric" var address:string = "lee" } one.name
but lastly line produces error:
'one.type' not have fellow member named 'name'
how can access variable on struct?
it looks defined struct, didn't create instance of it. if create instance, can access name , address properties.
struct 1 { var name: string = "ric" var address: string = "lee" } var x = one() x.name
it may confusing because can set default values in definition, may create instantiating something.
swift struct
No comments:
Post a Comment