Skip to content

Instantly share code, notes, and snippets.

@igal
Created March 18, 2009 00:32
Show Gist options
  • Save igal/80856 to your computer and use it in GitHub Desktop.
Save igal/80856 to your computer and use it in GitHub Desktop.
Diophanties if 1/2 were integer
# @MarkusQ ~Diophantines would be easier if 1/2 were an integer~
class Float
def kind_of_with_easier_diophantines?(klass)
return self == 0.5 && klass == Integer || kind_of_without_easier_diophantines?(klass)
end
alias kind_of_without_easier_diophantines? kind_of?
alias kind_of? kind_of_with_easier_diophantines?
end
=begin
(0.5).kind_of?(Integer) # => true
(0.6).kind_of?(Integer) # => false
=end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment