self::getArg always returns a string

Game development with Board Game Arena Studio
Post Reply
User avatar
pikiou
Posts: 389
Joined: 03 October 2011, 05:36

self::getArg always returns a string

Post 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 ^^
User avatar
Rudolf
Posts: 566
Joined: 24 December 2011, 23:04

Re: self::getArg always returns a string

Post by Rudolf »

put like this: (self::getArg("y", AT_posint, true))+4 = 29
User avatar
pikiou
Posts: 389
Joined: 03 October 2011, 05:36

Re: self::getArg always returns a string

Post 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.
User avatar
Rudolf
Posts: 566
Joined: 24 December 2011, 23:04

Re: self::getArg always returns a string

Post 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 :)
User avatar
sourisdudesert
Administrateur
Posts: 4630
Joined: 23 January 2010, 22:02

Re: self::getArg always returns a string

Post 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?
Post Reply

Return to “Developers”