Skip to content

Instantly share code, notes, and snippets.

@shepmaster
Created December 19, 2012 21:31
Show Gist options
  • Select an option

  • Save shepmaster/4340718 to your computer and use it in GitHub Desktop.

Select an option

Save shepmaster/4340718 to your computer and use it in GitHub Desktop.
class Wrapper
include Java::java.lang.Comparable
attr_reader :a
def initialize(a)
@a = a
end
def compare_to(x)
puts 'called'
a <=> x.a
end
def to_s
"|#{a}|"
end
end
describe Wrapper do
it do
a = [Wrapper.new(0), Wrapper.new(-10)].to_java
Java::java.util.Arrays.sort(a)
puts a.inspect
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment