Skip to content

Instantly share code, notes, and snippets.

@djberg96
Created February 5, 2021 16:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save djberg96/fcbff4c0d0651209a932e6872121bb0b to your computer and use it in GitHub Desktop.
Save djberg96/fcbff4c0d0651209a932e6872121bb0b to your computer and use it in GitHub Desktop.
class Foo
include Comparable(self)
getter name : String
getter age : Int32
def initialize(@name, @age)
end
def <=>(other : self)
age <=> other.age
end
end
class Bar < Foo
end
f1 = Foo.new("Dan", 51)
b1 = Bar.new("Joe", 35)
p f1 > b1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment