• AnAverageSnoot@lemmy.ca
    link
    fedilink
    English
    arrow-up
    10
    ·
    edit-2
    2 days ago

    Your variables are already booleans, so you can just write:

    if wearing_glasses and is_brightly_lit

    • pretzelz@lemmy.world
      link
      fedilink
      arrow-up
      12
      arrow-down
      1
      ·
      2 days ago

      Are they though? Maybe they are inputs that haven’t been sanitised but the language has two kinds of equals and is you use the double equals then it tries to coerce it for you. Lol that with would be silly!

      • Warl0k3@lemmy.world
        link
        fedilink
        arrow-up
        4
        ·
        edit-2
        2 days ago

        The compiler/interpreter/etc will convert it to the most efficient implementation regardless of what you the human type. If you’re used to the if [boolean] convention use that, if you’re used to if [boolean] == true use that, it does not matter except to style commissars.