Page 1 of 1
self::getArg always returns a string
Posted: 05 April 2013, 02:25
by pikiou
One would expect self::getArg("y", AT_posint, true) to return an integer, but it returns the string of an integer, e.g "25" instead of 25.
Is it intended?
If so, I'll add something on the wiki about it to save other devs the trouble of handling "25"+4 in a JS script when they thought it'd be 25+4 ^^
Re: self::getArg always returns a string
Posted: 05 April 2013, 16:28
by Rudolf
put like this: (self::getArg("y", AT_posint, true))+4 = 29
Re: self::getArg always returns a string
Posted: 05 April 2013, 18:01
by pikiou
"25"+4 works fine in PHP and ("25")+4 doesn't work in JS, so I'm not sure what to do with your advice ^^
Actually I know how to handle it, I'm just wandering if the behavior of self::getArg should be changed or documented.
Re: self::getArg always returns a string
Posted: 05 April 2013, 18:39
by Rudolf
oups sorry! I changed somz behaviour like that like 't'+i+j in 't'+(i+j)... but I answered too quickly to your post

Re: self::getArg always returns a string
Posted: 08 April 2013, 14:55
by sourisdudesert
Hello Pikiou,
Thank you for this remark.
Indeed, this is probably unintended, but this had no consequences until then. I'll fixed this on the next release.
Cheers,
PS: did you meet some situation where this cause an issue in your code?