• @[email protected]
      link
      fedilink
      212 days ago

      Though, obviously I had to come up with some ridiculous solutions:

      bool IsEven(int i) => ((Func<string, bool>)(s => s[^1] == 48))($"{i:B}");
      

      This one works without conditionals :)

      bool IsEven(int i)
      {
          try
          {
              int _ = (i & 1) / (i & 1);
          }
          catch (Exception)
          {
              return true;
          }
      
          return false;
      }
      
      • Lemminary
        link
        fedilink
        111 days ago

        s[^1]

        Ohh wow, I’ve been learning it casually for years, and I didn’t know that existed in C#. I guess I should go back and hit the books some more.