Skip to content

Instantly share code, notes, and snippets.

@iliabylich
Created August 28, 2015 15:52
Show Gist options
  • Save iliabylich/78e20d0d2890e82ad354 to your computer and use it in GitHub Desktop.
Save iliabylich/78e20d0d2890e82ad354 to your computer and use it in GitHub Desktop.
module ComparesByValue
def <=>(other)
self.value <=> other.value
end
end
class A < Struct.new(:value)
include ComparesByValue
include Comparable
end
puts A.new(1) < A.new(2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment