core/src/main/java/org/jruby/RubyBasicObject.java
@Override
    public int compareTo(IRubyObject other) {
        final Ruby runtime = metaClass.runtime;

        IRubyObject cmp = invokedynamic(runtime.getCurrentContext(), this, OP_CMP, other);

        // if RubyBasicObject#op_cmp is used, the result may be nil (not comparable)
        if ( ! cmp.isNil() ) {
            return (int) cmp.convertToInteger().getLongValue();
        }

        /* We used to raise an error if two IRubyObject were not comparable, but
         * in order to support the new ConcurrentHashMapV8 and other libraries
         * and containers that arbitrarily call compareTo expecting it to always
         * succeed, we have opted to return 0 here. This will allow all
         * RubyBasicObject subclasses to be compared, but if the comparison is
         * not valid we they will appear the same for sorting purposes.
         *
         * See https://jira.codehaus.org/browse/JRUBY-7013
         */
        return 0;
    }
/**
     * Compares this Ruby object with another.
     *
     * @param other another IRubyObject
     * @return 0 if equal,
     *         &lt; 0 if this is less than other,
     *         &gt; 0 if this is greater than other
     */
Compares this Ruby object with another.
@param other another IRubyObject
@return 0 if equal,
< 0 if this is less than other,
> 0 if this is greater than other
Compares this Ruby object with another . @param other another IRubyObject @return 0 if equal < 0 if this is less than other > 0 if this is greater than other
@Override
    public int compareTo(IRubyObject other) {
        final Ruby runtime = metaClass.runtime;
        IRubyObject cmp = invokedynamic(runtime.getCurrentContext(), this, OP_CMP, other);
        if ( ! cmp.isNil() ) {
            return (int) cmp.convertToInteger().getLongValue();
        }
        /* We used to raise an error if two IRubyObject were not comparable, but
         * in order to support the new ConcurrentHashMapV8 and other libraries
         * and containers that arbitrarily call compareTo expecting it to always
         * succeed, we have opted to return 0 here. This will allow all
         * RubyBasicObject subclasses to be compared, but if the comparison is
         * not valid we they will appear the same for sorting purposes.
         *
         * See https://jira.codehaus.org/browse/JRUBY-7013
         */
        return 0;
    }
@ Override public int compareTo ( IRubyObject other ) { final Ruby runtime = metaClass . runtime ; IRubyObject cmp = invokedynamic ( runtime . getCurrentContext ( ) , this , OP_CMP , other ) ; if ( ! cmp . isNil ( ) ) { return ( int ) cmp . convertToInteger ( ) . getLongValue ( ) ; } /* We used to raise an error if two IRubyObject were not comparable, but
         * in order to support the new ConcurrentHashMapV8 and other libraries
         * and containers that arbitrarily call compareTo expecting it to always
         * succeed, we have opted to return 0 here. This will allow all
         * RubyBasicObject subclasses to be compared, but if the comparison is
         * not valid we they will appear the same for sorting purposes.
         *
         * See https://jira.codehaus.org/browse/JRUBY-7013
         */ return 0 ; }
Compares this Ruby object with another.
Compares this Ruby object with another .
// if RubyBasicObject#op_cmp is used, the result may be nil (not comparable)