![]() |
|
|
Issue Type:
|
Bug
|
Affects Versions:
|
JRuby 1.7.0 |
Assignee:
|
Thomas E Enebo
|
Created:
|
26/Oct/12 2:06 AM
|
Description:
|
It seems that the behaviour of == operator changed between jruby 1.6.8 and 1.7.0. See the following:
As for me:
- A == B should always behave in exactly the same way as B == A (equality should be symmetric by definition)
- comparing objects should never throw exceptions unless some class has buggy implementation of comparison
Here, I don't understand why Ruby's == calls Java compareTo() instead of equals(). java.util.Date.compareTo() is allowed to throw a ClassCastException() in this case, because Date implements Comparable<Date>, so its compareTo() method requires a Date instance as an argument due to the method signature. Personally I don't think that calling Java's compareTo() is a good idea in any case, even for numerical types (Integer etc.), because they always expect object of the same type, while Ruby's == operator checks if both objects are equal, allowing them to be of different types.
|
Environment:
|
jruby 1.7.0 (1.9.3p203) 2012-10-22 ff1ebbe on Java HotSpot(TM) 64-Bit Server VM 1.6.0_37-b06 [linux-amd64] run from rvm 1.16.17 (stable)
|
Project:
|
JRuby
|
Priority:
|
Major
|
Reporter:
|
Piotr Kubowicz
|
|
|
|
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators.
For more information on JIRA, see: http://www.atlassian.com/software/jira
|
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email