Ruby: Is there a right way to indent a case statement?

indentation, ruby, switch-statement

Solution

The consensus is to indent `when` as the same level as `case`.

case sym
when :foo then ...
when :bar then ...
else ...
end

I think this is well established, and have not seen any authentic source that claims otherwise.

Problem

A number of blogs and tutorial have different indentations when they implement a case statement. Each have different indentation in reference to the 'when' lines. Is there a best practice for indenting when using a case loop?

Original source