What naming convention do you use for a situation ...
# getting-started
f
What naming convention do you use for a situation like this:
m
I would keep this as it is. Also it might be better asking in #codingconventions
💯 2
f
Sorry, next time
u then use the
this
keyword to access the property?
m
This class will only have one property called name. In Java terms, the name field after User is just a constructor parameter and not visible anywhere else. To demonstrate, rename it to inName and try to access it on a constructed User.
f
it's visible in an init block tho
where it uses the constructor param and not the property
m
The
init
block is the constructor. So, in that case, you'd have to use
this
and it would refer to the property, name, and not the 'constructor parameter' name.
f
Thanks
Also, there is no way to move this initialization logic into the constructor right?
the
toUpperCase
call
m
If you mean inside the parenthesis, then no. It's just for property and default definitions. What you have will only occur at construction time, so it effectively is 'in the constructor'.