Actions
Feature #16260
closedSymbol#to_proc behaves like lambda, but doesn't aknowledge it
    Feature #16260:
    Symbol#to_proc behaves like lambda, but doesn't aknowledge it
  
Description
Seems that Symbol#to_proc returns Proc that has lambda semantics:
proc = :+.to_proc
proc.call(1, 2)   # => 3
proc.call([1, 2]) # ArgumentError (wrong number of arguments (given 0, expected 1))
But if you ask...
proc.lambda? # => false
That seems to be an inconsistency, which I'd like to clarify. There are obviously two ways to fix it:
- Make it respond truetolambda?(and mention the semantics in docs)
- Make it behave like non-lambda.
The second one seems to produce some useful behavior:
# Currently:
[1, 2].zip([3, 4]).map(&:+) # ArgumentError (wrong number of arguments (given 0, expected 1))
# With non-lambda:
class Symbol
  def to_proc
    proc { |o, *a| o.send(self, *a) }
  end
end
[1, 2].zip([3, 4]).map(&:+) # => [4, 6] 
Probably all of it was discussed when Symbol#to_proc was introduced, but as old NEWS-files doesn't link to tickets/discussions, I can't find the reasoning for current behavior.
Actions