Is there any guidance of what to expect from the AutoHotkey v2 type system? I noticed recently that it was possible to input objects into string functions such as Trim({prop: "value"}).
I am wondering if functions such as Trim() will eventually call toString(), like in Java. This seems to be the current behavior of String() in v2.
Functions that require strings also accepting objects
Re: Functions that require strings also accepting objects
Expectations are documented for each function. Trim specifically says it requires a string and does not even support numbers.
It has always been possible, but not exactly valid. For v1, "If an object is used in any context where an object is not expected, it is treated as an empty string." This is still true for functions in v2 that don't explicitly implement type checking, due to cost vs. benefit and implementation reasons. Before the final v2.0 release, my intention is to change the way that built-in functions are linked into the script so that type checking and coercion can be performed for all functions in one place (among other reasons).I noticed recently that it was possible to input objects into string functions
Yes. See "coercion" above.functions such as Trim() will eventually call toString()
Return to “AutoHotkey Development”
Who is online
Users browsing this forum: No registered users and 35 guests