I've been looking through a number of scripts recently, and noticed that the most revered and more experienced scripters use && where and could be used. I know that there's a bug in XP for and, but is it the same for VX or is it just personal preference?
Do they even do different things?
"and does the same as &&, but is a lower priority operator."
Taken straight from the RPGVX help file. I'm not sure about their exact priorities though. They're pretty much interchangeable.
I generally use && for it (similarly I use || for or), but that's because I come from a C++ background where it's used like that. But there's not too much difference between the two as far as I know, so it's probably just preference. (Edit: except for the priorities as Cozzie says).
I don't know much about RMXP though, only VX, so whether there are any issues that have remained in things like && and 'and' I have no idea.
Righto, so I guess it's mainly a preference thing. I prefer and.
@cozzie, it's so easy to miss things in the help file, isn't it?
a = true && false
=> false # a is false
a = true and false
=> false # a is true
&& for me makes more sense, and if I want to use 'and', I'll use && with some parentheses.
::
[]
**
-(unary) +(unary) ! ~
* / %
+ -
<< >>
&
| ^
> >= < <=
<=> == === != =~ !~
&&
||
.. ...
?:(conditional operator)
=(+=, -= ... )
not
and or
Its is safer to use a "&&" to avoid the statement from being interpreted wrong, though I personally use () in such situations anyway just to make the code a little more over-viewable.