Ruby idiom for do_two_simple_things if something_is_true
ruby
Solution
I agree with @NedBatchelder that your original code is probably best. Others have pointed out that in your particular example, you can use `return puts 'error'`.
Still, for the sake of learning, you can group multiple statements with parentheses, and therefore use a small number of statements in places where you could otherwise use only one. You said:
# it would be great if this would work because it is short and readable
puts 'error' and return if something_is_true
You can do this with:
(puts 'error'; return) if something_is_true
Problem
For instance, this takes 4 lines which is too much space for such a simple operation: ``` if something_is_true puts 'error' return end ``` this one is a one-liner but looks awkward. ``` if something_is_true; puts 'error'; return; end ``` Can we do something like ``` # it would be great if this would work because it is short and readable puts 'error' and return if something_is_true ```