General statistics
List of Youtube channels
Youtube commenter search
Distinguished comments
About
p11
ThePrimeTime
comments
Comments by "p11" (@porky1118) on "Prime Reacts: From C to C++ to Rust to Haskell" video.
The never nester video made me rework most of my Rust programs. I now use early returns or early continues everywhere. My loops usually look like this: for ... { if (...) continue; ... break; } I started to question why loops loop by default.
2
16:10 A while ago I used the "=>" feature in C# (which allows defining functions without the curly braces). So instead of "bool something(...) { return ...; }" I'd just write "bool something(...) => ...;" Then I had something like this: "=> (a && (b || c)", where a, b and c are somewhat complicated expressions. But then I refactored it with a lot of early returns. { if (!a) return false; if (b) return true; if (c) return true; return false; } Much nicer, since that's what I was thinking anyway when interpreting the &| expression. I look at the original code and think "So if a is false, this returns false. Otherwise it goes in the or-expression, so if one of them is true, it returns true" or something like that.
1