Bug #8359
closed
If p is a proc, p.call(x) can take a block, but p[x] cannot
Added by alexeymuranov (Alexey Muranov) almost 11 years ago.
Updated almost 11 years ago.
Description
=begin
format = lambda { |l, s = '', &w|
l.map {|e| w ? w[e] : e}.join(s)
}
format.call([1, 2], "\n") {|c| "[ #{ c } ]"}
=> "[ 1 ]\n[ 2 ]"¶
format[[1, 2], "\n"] {|c| "[ #{ c } ]"}
=> SyntaxError: unexpected { arg, expecting end-of-input¶
=end
- Status changed from Open to Rejected
=begin
You can pass a block to (({ #[] })) in two ways:
format[[1, 2], "\n", &proc {|c| "[ #{ c } ]"}]
or:
format.[]([1, 2], "\n") {|c| "[ #{ c } ]"}
=end
=begin
Ok, maybe this is not a bug report but a feature request. Is there a reason to not allow (({ p[x] do ...}))?
=end
Also available in: Atom
PDF
Like0
Like0Like0