[#65451] [ruby-trunk - Feature #10333] [PATCH 3/1] optimize: "yoda literal" == string — ko1@...
Issue #10333 has been updated by Koichi Sasada.
ko1@atdot.net wrote:
Eric Wong <normalperson@yhbt.net> wrote:
Eric Wong <normalperson@yhbt.net> wrote:
On 2014/10/09 11:04, Eric Wong wrote:
SASADA Koichi <ko1@atdot.net> wrote:
[#65453] [ruby-trunk - Feature #10328] [PATCH] make OPT_SUPPORT_JOKE a proper VM option — ko1@...
Issue #10328 has been updated by Koichi Sasada.
[#65559] is there a name for this? — Xavier Noria <fxn@...>
When describing stuff about constants (working in their guide), you often
On 2014/10/09 20:41, Xavier Noria wrote:
On Thu, Oct 9, 2014 at 1:59 PM, Nobuyoshi Nakada <nobu@ruby-lang.org> wrote:
[#65566] [ruby-trunk - Feature #10351] [Open] [PATCH] prevent CVE-2014-6277 — shyouhei@...
Issue #10351 has been reported by Shyouhei Urabe.
[#65741] Re: [ruby-cvs:55121] normal:r47971 (trunk): test/ruby/test_rubyoptions.rb: fix race — Nobuyoshi Nakada <nobu@...>
On 2014/10/16 10:10, normal@ruby-lang.org wrote:
Nobuyoshi Nakada <nobu@ruby-lang.org> wrote:
2014-10-16 12:48 GMT+09:00 Eric Wong <normalperson@yhbt.net>:
[#65753] [ruby-trunk - Feature #10333] [PATCH 3/1] optimize: "yoda literal" == string — ko1@...
Issue #10333 has been updated by Koichi Sasada.
[#65818] [ruby-trunk - Feature #10351] [PATCH] prevent CVE-2014-6277 — shyouhei@...
Issue #10351 has been updated by Shyouhei Urabe.
[ruby-core:65529] [ruby-trunk - Feature #10343] Postfix notations for `when` and `else` inside `case` statement
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/