Issue #7969 has been reported by prijutme4ty (Ilya Vorontsov). ---------------------------------------- Bug #7969: Integer binary_op Float operations doesn't use coercion https://bugs.ruby-lang.org/issues/7969 Author: prijutme4ty (Ilya Vorontsov) Status: Open Priority: Normal Assignee: Category: Target version: ruby -v: 1.9.3; 2.0.0 I'm trying to override #coerce method on Float. But I found that redefining Float#coerce makes no changes in behavior of code: 1 + 2.0 class Float def coerce(other) [2, 2] end end puts 1+2.0 # ==> 3.0 while result should be 4. Is it done due to perfomance considerations or it's just a bug? If it's intended is it a spec or realization specific feature?
on 2013-02-26 13:05
on 2013-02-26 13:34
Issue #7969 has been updated by nobu (Nobuyoshi Nakada). Status changed from Open to Rejected Intended behavior. coerce method is called if the peer is unknown to the receiver. ---------------------------------------- Bug #7969: Integer binary_op Float operations doesn't use coercion https://bugs.ruby-lang.org/issues/7969#change-37098 Author: prijutme4ty (Ilya Vorontsov) Status: Rejected Priority: Normal Assignee: Category: Target version: ruby -v: 1.9.3; 2.0.0 I'm trying to override #coerce method on Float. But I found that redefining Float#coerce makes no changes in behavior of code: 1 + 2.0 class Float def coerce(other) [2, 2] end end puts 1+2.0 # ==> 3.0 while result should be 4. Is it done due to perfomance considerations or it's just a bug? If it's intended is it a spec or realization specific feature?
Please log in before posting. Registration is free and takes only a minute.
Existing account
(Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
Log in with Google account | Log in with Yahoo account
No account? Register here.