< :前の番号
^ :番号順リスト
> :次の番号
P :前の記事(スレッド移動)
N :次の記事(スレッド移動)
|<:前のスレッド
>|:次のスレッド
^ :返事先
_:自分への返事
>:同じ返事先を持つ記事(前)
<:同じ返事先を持つ記事(後)
---:分割してスレッド表示、再表示
| :分割して(縦)スレッド表示、再表示
~ :スレッドのフレーム消去
.:インデックス
..:インデックスのインデックス
Issue #13879 has been updated by nobu (Nobuyoshi Nakada).
Description updated
Status changed from Open to Rejected
That `when` clause continues by the last comma, so your example equals the following code syntactically.
```
x = 'foobar'
case x
when 'a','b','c', x = 5
end
puts x
```
```
x = 'foobar'
case x
when 'a','b','c', puts 5
end
```
But command calls (method calls with arguments but no parentheses) can't be there, because of the precedence.
----------------------------------------
Bug #13879: [Not sure if a bug or not] case/when menus and trailing ',' commas in when clauses
https://bugs.ruby-lang.org/issues/13879#change-66536
* Author: shevegen (Robert A. Heiler)
* Status: Rejected
* Priority: Normal
* Assignee:
* Target version:
* ruby -v: ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-linux]
* Backport: 2.2: UNKNOWN, 2.3: UNKNOWN, 2.4: UNKNOWN
----------------------------------------
Hello,
I am not sure if the following is a bug or a feature.
```ruby
x = 'foobar'
case x
when 'a','b','c',
x = 5
end
puts x
```
Works fine.
But this here:
```ruby
x = 'foobar'
case x
when 'a','b','c',
puts 5
end
```
Leads to this error:
syntax error, unexpected tINTEGER, expecting keyword_do or '{' or '('
Is this deliberately so? My confusion is that case/when works fine
in one case, but leads to an error in another case. I am not
sure if it is a bug or not, but I believe in the first case,
the user may have not wanted to put a trailing ',' there and
simply forgot to remove it. That is actually how I found out about
this behaviour, since I have a huge case/when menu and sometimes
make typos when re-arranging entries, including such trailing ','
via copy/paste jobs. :)
If it is a bug then perhaps it can be fixed; if it is not a
bug, perhaps the official documentation could explain this
feature? Or perhaps if trailing ',' are not useful, there
may be a warning issued or something in the first case.
Anyway, I am just reporting this in case nobody knows about
this - feel free to close this issue at any moment in time.
Thanks.
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>