• Just a reminder that providing specifics on, sharing links to, or naming websites where ROMs can be accessed is against the rules. If your post has any of this information it will be removed.
  • Our friends from the Johto Times are hosting a favorite Pokémon poll - and we'd love for you to participate! Click here for information on how to vote for your favorites!
  • Scottie, Todd, Serena, Kris - which Pokémon protagonist is your favorite? Let us know by voting in our poll!
  • Welcome to PokéCommunity! Register now and join one of the best fan communities on the 'net to talk Pokémon and more! We are not affiliated with The Pokémon Company or Nintendo.

What does || exactly mean?

  • 961
    Posts
    8
    Years
    • Age 22
    • Seen Nov 28, 2022
    I'm trying to understand coding in general and I think I know all of the symbols, but this one I'm still not exactly sure about. I googled it quickly but couldn't really find much since google doesn't take "||" in account when searching.
    What I thought it meant from the bits of code I read I concluded it would be something like "and", "and if" or perhaps "or if". If someone could answer this with certainty, I'd be able to use it and understand what those big "if"'s that include them mean.

    I have two small examples here from PokeBattle_MoveEffects:

    Code:
        if attacker.status==0 ||
          (attacker.status==PBStatuses::PARALYSIS && !opponent.pbCanParalyze?(attacker,false,self)) ||
          (attacker.status==PBStatuses::SLEEP && !opponent.pbCanSleep?(attacker,false,self)) ||
          (attacker.status==PBStatuses::POISON && !opponent.pbCanPoison?(attacker,false,self)) ||
          (attacker.status==PBStatuses::BURN && !opponent.pbCanBurn?(attacker,false,self)) ||
          (attacker.status==PBStatuses::FROZEN && !opponent.pbCanFreeze?(attacker,false,self))
          @battle.pbDisplay(_INTL("But it failed!"))
          return -1
        end
    Code:
        if attacker.gender==2 || opponent.gender==2 || attacker.gender==opponent.gender
     
    https://stackoverflow.com/questions/2083112/difference-between-or-and-in-ruby
    An important note as to why || is used over explicitly saying 'or' is operator precedence

    For possible future reference, https://symbolhound.com/ is a good search engine that supports special characters. It's very helpful for specific coding questions.

    Thanks for your help. I've also been learning Ruby (programming language Essentials uses) the last few days to help me out in the future. I did encounter || meaning or there, but didn't know about precedences with && || and !. I'll be aware of that in the future.
     
    Last edited:
    Back
    Top