Code: Select all
obj := ["Hello World"] ;// store in variable
test % obj ;// works
test % obj := ["Hello World"] ;// works
test % ["Hello World"] ;// does not work
test(arg) { ;// arg is not ByRef
MsgBox % IsObject(arg)
MsgBox % arg[1]
}
Code: Select all
obj := ["Hello World"] ;// store in variable
test % obj ;// works
test % obj := ["Hello World"] ;// works
test % ["Hello World"] ;// does not work
test(arg) { ;// arg is not ByRef
MsgBox % IsObject(arg)
MsgBox % arg[1]
}
Object.SetCapacity(0)
MaxItems: The maximum number of key-value pairs the object should be able to contain before it must be automatically expanded. If less than the current number of key-value pairs, the object is shrunk to fit.
That seems like the wrong point to make. If the "99% of the time" only covers moments that you don't want the object to be freed, or cases where the variable is local and will be freed automatically, then sure. It is absolutely necessary to do obj := "" (or something equivalent) if the variable isn't going to be freed by some other means.fincs wrote:(which is unnecessary 99% of the time).
It looks like you did not read and understand the quoted documentation either.obj.SetCapacity(0) wipes an object's contents; but does not free it completely.
lexikos wrote: SetCapacity(0) does not free the object nor wipe its contents. "Shrunk to fit" means that excess unused space is reclaimed by reallocating an internal array. All contents are preserved and the end result is an object whose capacity is equal to the number of key-value pairs it contains.
lexikos wrote:Command syntax doesn't support objects.
Thanks for clarifying. Are there plans to support objects for command syntax?lexikos wrote:Objects are always passed by reference
Does it make sense?... If less than the current number of key-value pairs, the object is shrunk to fit the current number.
Whatever your intent, two separate users misunderstood. Clarity > Brevity imo. Pretty much whenever people have misunderstandings reading the docs, that is a time to improve the docs. This is for everyone's benefit, including yours. Less questions in the forum asking for your clarificationlexikos wrote:guest3456: I was going for brevity. Does anyone think "shrunk to fit" actually meant removing everything from the object? That doesn't make sense.
I take it back. As of v2.0-a049, Coco's code works.I wrote:Command syntax doesn't support objects.
Return to “AutoHotkey Development”
Users browsing this forum: Marium0505 and 26 guests