Page 2 of 2

Re: About meta-functions change, Properties?

Posted: 12 Feb 2020, 10:38
by bourdin07
I dont know if its possible but I want to set a value to a property like this

Code: Select all

class MyClass
{
	MyProp
	{
		set
		{
			; Here I want some logic (very important)
			; then set the value to this MyProp
			
			return this.MyProp := value
		}
	}
}
The problem is that there is infinite loop, any idea how to set value

Re: About meta-functions change, Properties?

Posted: 04 Aug 2020, 05:58
by swagfag
it cant be done.
there needs to be some other place where u store ur data in/retrieve ur data from, like a differently-named instance variable on the object or a static variable inside the getter/setter(or a variable bound to the getter/setter, get creative)
the most straightforward solution is storing it inside a similarly named value property, eg

Code: Select all

class MyClass
{
	_MyProp := 'some default value'
	
	MyProp
	{
		set
		{
			; Here I want some logic (very important)
			; then set the value to this MyProp
			
			return this._MyProp := value
		}
	}
}