From: sawadatsuyoshi@... Date: 2014-10-08T16:42:45+00:00 Subject: [ruby-core:65528] [ruby-trunk - Feature #10343] [Open] Postfix notations for `when` and `else` inside `case` statement Issue #10343 has been reported by Tsuyoshi Sawada. ---------------------------------------- Feature #10343: Postfix notations for `when` and `else` inside `case` statement https://bugs.ruby-lang.org/issues/10343 * Author: Tsuyoshi Sawada * Status: Open * Priority: Normal * Assignee: * Category: * Target version: ---------------------------------------- In `case` statements, the condition part are not always uniform in length, and especially, `else` is short. When we want to put each `when` statement in a single line, they are not always aligned, and are hard to read. ~~~ruby case foo when some_very_long_condition then "a" when short_cond then "bb" when some_long_condition then "ccc" else "dddd" end ~~~ I think it would be better if we can do postfix notations with `when` and `else` inside `case` statement as below. ~~~ruby case foo "a" when some_very_long_proc "bb" when short_regex "ccc" when some_long_regex "dddd" else end ~~~ The length of `"a"`, `"bb"`, `"ccc"`, `"dddd"`, etc. can also vary, but they are usually more homogenuous with respect to length than the condition, and easier to align. And, it is these values that we are interested in, rather than the conditional parts. Furthermore, this notation is closer to the case-like notation standardly used in mathematics for conditions, so it would be easier to read for those who are familiar with mathematics. ~~~ x! = 1 (x = 0) x (x - 1)! (otherwise) ~~~ -- https://bugs.ruby-lang.org/