Skip to content

Commit

Permalink
Add historical reference to indent-when-to-case
Browse files Browse the repository at this point in the history
Justifying `indent-when-to-case` by referencing early literature feels a little weak. The history goes way back to at least the C language.

There's an excellent discussion on https://stackoverflow.com/questions/4509039/why-the-strange-indentation-on-switch-statements
  • Loading branch information
kmayer authored and bbatsov committed Jul 4, 2018
1 parent 577765b commit 992f904
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion README.md
Expand Up @@ -318,7 +318,10 @@ Translations of the guide are available in the following languages:

* <a name="indent-when-to-case"></a>
Indent `when` as deep as `case`. This is the style established in both
"The Ruby Programming Language" and "Programming Ruby".
"The Ruby Programming Language" and "Programming Ruby". Historically it
is derived from the fact that `case` and `switch` statements are not blocks,
hence should not be indented, and the `when` and `else` keywords are labels
(compiled in the C language, they are litterally labels for `JMP` calls).
<sup>[[link](#indent-when-to-case)]</sup>

```ruby
Expand Down

0 comments on commit 992f904

Please sign in to comment.