[#70843] Re: [ruby-cvs:58952] hsbt:r51801 (trunk): * lib/rubygems: Update to RubyGems HEAD(fe61e4c112). — Eric Wong <normalperson@...>
hsbt@ruby-lang.org wrote:
3 messages
2015/09/17
[ruby-core:70819] [Ruby trunk - Bug #11528] Possible parsing bug. Possibly just confusing.
From:
olleicua@...
Date:
2015-09-15 18:49:34 UTC
List:
ruby-core #70819
Issue #11528 has been updated by Antha Auciello.
I'm realizing this is probably intentional: http://blog.plataformatec.com.br/2014/07/ruby-blocks-precedence/
It looks like I'm not allowed to close my own bug. Sorry for the distraction.
----------------------------------------
Bug #11528: Possible parsing bug. Possibly just confusing.
https://bugs.ruby-lang.org/issues/11528#change-54200
* Author: Antha Auciello
* Status: Open
* Priority: Normal
* Assignee:
* ruby -v: 2.2.2p95
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN
----------------------------------------
Not sure if this is intentional behavior but I found it confusing:
code:
~~~
def render(args)
p args.to_a
end
print 'functionally (without parentheses): '
render "foobar".length\
.to_s(2)\
.split('')\
.map do |d|
{digit: d}
end
print 'functionally (with parentheses): '
render("foobar".length\
.to_s(2)\
.split('')\
.map do |d|
{digit: d}
end)
print 'with an intermediate variable: '
data = "foobar".length\
.to_s(2)\
.split('')\
.map do |d|
{digit: d}
end
render data
~~~
output:
~~~
functionally (without parentheses): ["1", "1", "0"]
functionally (with parentheses): [{:digit=>"1"}, {:digit=>"1"}, {:digit=>"0"}]
with an intermediate variable: [{:digit=>"1"}, {:digit=>"1"}, {:digit=>"0"}]
~~~
--
https://bugs.ruby-lang.org/