Is there a shorthand if (without else) statement in Ruby on Rails?

ruby

Solution

You can use post conditions (don't mind the name, it will be evaluated before the code. And `do_something` will only be executed if condition evaluates to truthy value (i.e. not `nil` or `false`)).

do_something if a

Problem

I know there is a shorthand one-line if/else statement in Ruby: ``` a ? b : c ``` Is there one for just a single `if` statement? Instead of writing this: ``` if a # do something end ``` Is there a shorthand version of this?

Original source