Skip to content

Instantly share code, notes, and snippets.

@richo
Last active December 17, 2015 08:49
Show Gist options
  • Save richo/5582441 to your computer and use it in GitHub Desktop.
Save richo/5582441 to your computer and use it in GitHub Desktop.
def cmp(this, type=nil)
type ||= this.class
cmp_with_type(this, type)
end
def cmp_with_type(this, type)
if type == String
StringComparator.new(this)
elsif type == Fixnum or type == Bignum
NumberComparator.new(this)
else
raise "No comparator for #{type}"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment