Issue #10343 has been updated by gogo tanaka.


I'm not sure how we can implement this.. anyway it looks not but for me.

What I afraid of most is .. parsing this syntax well?


Aside from that, we can realize what you want for now.

```
case foo
when some_very_long_condition then "a"
when short_cond               then "bb"
when some_long_condition      then "ccc"
else                               "dddd"
end
```

I have to admire this is little bit ugly : (

Thank you.

----------------------------------------
Feature #10343: Postfix notations for `when` and `else` inside `case` statement
https://bugs.ruby-lang.org/issues/10343#change-49301

* 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/