Is it ok to use syntax like this:
Object.parent.property
or should I restrict it to one dot and one level only?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
In general, it is okay to use:
However, if there are structures involved then it might not work. Consider the following class declaration:
In this case, the
centreproperty is of typeNSPoint, a structure (not a class!) that declares two members,xandy. Reading thexcoordinate works:and is equivalent to:
but writing the
xcoordinate doesn’t:because the left part of the assignment, called an lvalue, is not assignable. The assignment is trying to change a member variable of a return value, namely the structure returned by
[circle centre].You’ll have to to write this instead: