[Proposal] Support the unless
keyword like from Ruby
#9547
-
You know that feeling when you're writing code, and your if (!condition) just looks... a bit clunky? Like wearing socks with sandals to a black-tie event? We've all been there! Currently, our code often ends up looking like this: if(!boolean) {
do_work();
} While it gets the job done, it lacks a certain je ne sais quoi. It's perfectly functional, sure, but imagine a world where our logic could flow a little more naturally, a little more eloquently, like a perfectly brewed cup of coffee on a Monday morning. ☕️ Why wrestle with double negatives when we don't have to? Many of us have admired from afar the elegant simplicity of languages like Ruby, which offer an unless() statement. It's like having a dedicated "if not" button that just feels right! With unless(condition), our example transforms into something far more readable and, dare I say, delightful: unless(boolean) {
do_work();
} This tiny tweak could bring a wave of joy to our coding experience, making our conditions clearer, our intentions more obvious, and our code just a little bit snappier. It's not just about saving a character or two; it's about embracing a more intuitive way to express our logic. What do you say? Ready to make unless() a thing? 🤔 |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 4 replies
-
See: |
Beta Was this translation helpful? Give feedback.
-
![]() |
Beta Was this translation helpful? Give feedback.
-
mildly related: |
Beta Was this translation helpful? Give feedback.
ah it was this one i missed: #560
what a shame, I've always known the .NET ecosystem to steal the best of other languages.