From: shyouhei@... Date: 2017-03-06T03:13:34+00:00 Subject: [ruby-core:79930] [Ruby trunk Misc#13283] Disable `&' interpreted as argument prefix warning when passing symbol to Enumerable#map Issue #13283 has been updated by Shyouhei Urabe. I'm also a member of the church of dropping parens if possible. I'm not against introducing some new syntax to pass symbol-as-a-proc without parens. But wonder if that works for this specific map case. The main concern is that map returns something. It is rarely used as a statement; rather it tends to be an expression. ```ruby q.map(&:w).e.r.t.y ... # cant omit ``` ---------------------------------------- Misc #13283: Disable `&' interpreted as argument prefix warning when passing symbol to Enumerable#map https://bugs.ruby-lang.org/issues/13283#change-63358 * Author: Dan Allen * Status: Open * Priority: Normal * Assignee: ---------------------------------------- A common idiom in Ruby is to pass a symbol reference to `Enumerable#map`, which in turn invokes the corresponding method on each entry. Case in point: ~~~ %(a b c).map &:upcase ~~~ Yet, when warnings are enabled, this line produces the following warning: ~~~ warning: `&' interpreted as argument prefix ~~~ Perhaps we can all agree that's what this statement *should* do, and in fact Ruby does it. So there's really no reason for this warning. The alternative, a bitwise operation on a symbol, makes little sense. That's especially when the bitwise operator is directly adjacent to the symbol. The workaround to squelch the warning is to add parentheses: ~~~ %(a b c).map(&:upcase) ~~~ However, it's one of the few cases in Ruby where parentheses are mandatory (for an isolated statement). For those of us who prefer to drop parentheses for code style, this is an irritation. It's also one of the most common warnings I've seen Ruby report when warnings are enabled, so it's also just noisy. Can this warning be removed? -- https://bugs.ruby-lang.org/ Unsubscribe: