From: jacknagel@... Date: 2014-09-22T16:04:37+00:00 Subject: [ruby-core:65215] [ruby-trunk - Bug #10277] Ampersand to_proc issues Issue #10277 has been updated by Jack Nagel. This seems correct to me. The `&` operator expects `to_proc` to return an actual `Proc`. `AmpersandMethod#to_proc` does *not* return a `Proc`, it returns a `Method`. In other words, ``` puts yielder(&AmpersandMethod.new.method(:mapper)) puts a.map(&AmpersandMethod.new.method(:mapper)) ``` here `to_proc` on the given object returns a `Proc`. ``` puts yielder(&AmpersandMethod.new) puts a.map(&AmpersandMethod.new) ``` here `to_proc` on the given object returns a `Method`, not a `Proc`. ---------------------------------------- Bug #10277: Ampersand to_proc issues https://bugs.ruby-lang.org/issues/10277#change-49048 * Author: Justin Ridgewell * Status: Open * Priority: Normal * Assignee: * Category: core * Target version: current: 2.2.0 * ruby -v: ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-darwin13.0] * Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN ---------------------------------------- I'm noticing weird inconsistencies when when returning a bound method in the #to_proc method when using &instance_object. When returning the bound method from #to_proc, it'll raise an error ("wrong argument type AmpersandMethod (expected Proc) (TypeError)", AmpersandMethod being my class name). However, if I explicitly #to_proc the bound method, everything works as normal. I've attached a small ruby script showing the problem. ---Files-------------------------------- ampersand-to_proc.rb (635 Bytes) -- https://bugs.ruby-lang.org/