Reputation: 11
In the answer by David Heffernan, he use assignment to read-only properties (see complete program example). There are two property: RecDirect and RecFunction. Both are read-only.
My question is why would one write to something that is read-only? Also I think properties are very flexible and useful. So why would one use properties and after all refer to corresponding underlying fields?
Upvotes: 1
Views: 306
Reputation: 8331
In the linked answer David did not write to read only property.
The Obj.RecDirect.A := 21;
dos not write to a read only property.
What this does is to use RedDirect
property first to retrieve reference to a Record object.
And then it uses A
property of that referenced Record to write a value of 21 to FA
field of that referenced Record. And if you take a look at property A
definition in that record you can see that is defined as Read/Write property.
Upvotes: 1