We have talked a lot about the Dynamic type, but now, we are going to talk about something else: properties.
Sometimes, you would like to be able to react to the access to an object's property. Whether this is when reading from or assigning to the property, the only way to do that is through the use of functions.
It would then be possible to use it with some code looking like this:
myObject.getValue(); //or myObject.setValue("This is my new value");
This is a non-natural way of accessing properties, and it can make the code really difficult to read, particularly if you are going to chain calls.
With properties, we will be able to define our functions setValue
and getValue
so that we can react to accesses to our properties. But what is so interesting with properties, is that we won't have to directly call our functions, we will just be able to access properties as if they were simple fields:
myObject.value; //or myObject.value = "This is my new value";
This syntax is really...