Project

General

Profile

Bug #8359

If p is a proc, p.call(x) can take a block, but p[x] cannot

Added by Alexey Muranov over 3 years ago. Updated over 3 years ago.

Status:
Rejected
Priority:
Normal
Assignee:
-
ruby -v:
2.0.0
[ruby-core:54739]

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

History

#1 [ruby-core:54740] Updated by Charlie Somerville over 3 years ago

  • 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

#2 [ruby-core:54741] Updated by Alexey Muranov over 3 years ago

=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