2 ms·
Ruby. (Technically Ruby does have a return keyword, but it's optional. Same goes for CoffeeScript, I believe.)
by rufo 16y ago
Ruby.
(Technically Ruby does have a return keyword, but it's optional. Same goes for CoffeeScript, I believe.)
- draegtun 16y agoditto for Perl.
- Andys 16y agoNot really: for example, if/else statements are not expressions whose results can be assigned to a variable like in Ruby.
- draegtun 16y agoThis thread is about needing an implicit return. So my "ditto" is 100% correct! But you are quite right that Perl if/else are statements and not expressions. Instead you can use the ternary operator: my $value = $cond == 1 ? 'true' : 'false'; And because of ditto for Perl you can also do following: my $value = do { if ($cond == 1) { 'true' } else { 'false' } };