4 ms·
ProTip: In both languages you can do the following: return number > 2;
by fnord123 10y ago
ProTip:
In both languages you can do the following:
return number > 2;
- kzrdude 10y agoBut that's different. Perl's variant isn't that intuitive.
- alfiedotwtf 10y agoAlso that was just an example. Another along the same line: x = 42 if y > 7; Rather than x = match y > 7 { true => 42, false => 0 }; Or even: foo() if bar(); Rather than: if bar() { foo() }
- kibwen 10y agoGiven how crucially important scopes are to Rust, this would be a uniquely poor fit. :P
- alfiedotwtf 10y agoYeah, I totally understand why not. Just my comments from the peanut gallery :)
- flogic 10y agoNot really the same thing. The Perl version is generally used as an early abort either from a subroutine or a loop. return if($number > 2); Is equivalent to: if($number > 2){ return; }
- fnord123 10y agoI didn't know that. Thanks for explaining it.