Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Serious help with |, ||, |=,&, &&, etc.

What does | do? what about ||? |=? &? What is the difference between |/||, and &/&&? I probably should know these already, but whatever.
 
| is or
|| is logical or
& is and
&& is logical and

the difference between the normal and logical forms is that the logical form performs short curciut evaluation

so if I do this
def test
p "Hello"
return true
end

false && test
you will see that the word Hello isn't produced, likewise if I do this

true || test
the word Hello isn't produced either

bool |= bool2 is the same as bool = bool | bool2
there is also an &= which is the same as bool = bool & bool2
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top