
module Comparable

  # Alternate name for comparison operator #<=>.
  #
  #   3.cmp(1)   #=>  1
  #   3.cmp(3)   #=>  0
  #   3.cmp(10)  #=> -1
  #
  def cmp(o)
    self<=>o
  end

end



#  _____         _
# |_   _|__  ___| |_
#   | |/ _ \/ __| __|
#   | |  __/\__ \ |_
#   |_|\___||___/\__|
#
=begin test

  require 'test/unit'

  class TCComparable < Test::Unit::TestCase

    def test_cmp
      assert_equal( -1, 3.cmp(4) )
      assert_equal(  0, 3.cmp(3) )
      assert_equal(  1, 3.cmp(2) )
    end

  end

=end
