Main Menu
  • Welcome to The RPG Maker Resource Kit.

[VX] && or and?

Started by pacdiggity, June 12, 2011, 02:48:56 AM

0 Members and 1 Guest are viewing this topic.

pacdiggity

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?
it's like a metaphor or something i don't know

cozziekuns

"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.

LoganF

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.
(Why do I always feel like it's the end of the world and I'm the last man standing?)

pacdiggity

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?
it's like a metaphor or something i don't know

IMP1

#4
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.

ForeverZero

::
[]
**
-(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.