Hello all,
Is there a way to have a property be public in scope, but read only?
Tim
Hello all,
Is there a way to have a property be public in scope, but read only?
Tim
Make it a Computed property and only implement the Get method.
or depending on its use. make it a constant
Hi Kem.
Thank you for your rapid reply! I have not yet used computed properties, but will try that out!
Thank you,
Tim
[quote=295471:@Tim Seyfarth]Hi Kem.
Thank you for your rapid reply! I have not yet used computed properties, but will try that out!
Thank you,
Tim[/quote]
Create a computed property and you’ll see it has a Set and a Get method in it. Simply remove the code in the Set method and it’ll be read only
In the Get method you write the code for what you want it to return when the property is accessed.
If your read-only property is an array use a method with no arguments returning the array as computed properties do not support arrays.
You’d have to return a copy of the array. Otherwise, changes made to the array would persist.