• FooBarrington@lemmy.world
    link
    fedilink
    arrow-up
    14
    ·
    1 year ago

    You can go one step further and use the Bang-Bang operator:

    !!m

    To be read as “Bang! Bang! You’re a boolean now!”

    • alokir@lemmy.world
      link
      fedilink
      arrow-up
      2
      ·
      1 year ago

      I might be in the minority but I prefer to do it like this: Boolean(m).

      It’s the same thing but less cool. On the flip side it’s easier to read when you have a line full of operators.

      • FooBarrington@lemmy.world
        link
        fedilink
        arrow-up
        7
        ·
        1 year ago

        Yep, that’s a much better way! It’s like the “goes down to” operator - a neat trick you should never use :)

        while (i --> 0) { ... }