@[email protected] to Programmer [email protected] • 12 days agoInfallible Codefeddit.ukimagemessage-square56fedilinkarrow-up1282cross-posted to: [email protected]
arrow-up1282imageInfallible Codefeddit.uk@[email protected] to Programmer [email protected] • 12 days agomessage-square56fedilinkcross-posted to: [email protected]
minus-square@[email protected]linkfedilink2•12 days agoThough, 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; }
minus-squareLemminarylinkfedilink1•11 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.
Though, obviously I had to come up with some ridiculous solutions:
This one works without conditionals :)
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.