About meta-functions change, Properties?

Get help for the alpha version of AutoHotkey v2 here. Please state the v2 version you are working with in the title when making a new topic.
bourdin07
Posts: 33
Joined: 23 Jun 2019, 12:57

Re: About meta-functions change, Properties?

12 Feb 2020, 10:38

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
swagfag
Posts: 4070
Joined: 11 Jan 2017, 17:59

Re: About meta-functions change, Properties?

04 Aug 2020, 05:58

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
		}
	}
}

Return to “AutoHotkey v2 Help”

Who is online

Users browsing this forum: No registered users and 2 guests