3 ms·
I haven't touched Perl in more than 20 years... ... but I (routinely) miss something like: $variable = something() if sanity_check() And do_something()
by eb0la 2y ago
I haven't touched Perl in more than 20 years...
... but I (routinely) miss something like:
$variable = something() if sanity_check()
And
do_something() unless $dont_do_that
- jononor 2y agoThere exists a ternary if statement? foo = something() if sanity_check else None Can replace None with foo (or any other expression), if desired.
- reportgunner 2y agoBoth work in python: variable = something() if sanity_check() else None do_something() if not dont_do_that else None
- c6401 2y agoAdditionally to the provided answers: if sanity_check(): variable = something() variable = sanity_check() and something (but the standard python two line way is more readable unless it's a throwaway single use code, then whatever)