Reputation: 15676
I tried doing this in a class declaration.
public var Thing : Thing = Thing()
It says,
Variable used within its own initial value
If I remove the assignment then it gives.
Thing used within its own type
So no luck. Is it possible to use the same name for the property as the type? Its possible in C# :) At present I have lower cased the property name.
Upvotes: 1
Views: 624
Reputation: 371
If the following doesn't work:
public var thing: Thing = Thing()
There error is likely in the init method of Thing
Upvotes: 0
Reputation: 285082
If you conform to the naming convention and declare variable names with a leading lowercase letter, it's possible.
public var thing : Thing = Thing()
Upvotes: 2