Skip to content

Commit

Permalink
Use 0 instead of zero
Browse files Browse the repository at this point in the history
  • Loading branch information
asterite committed Mar 13, 2019
1 parent debd4f9 commit dc0ba81
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/comparable.cr
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
#
# Including types must provide an `<=>` method, which compares the receiver against
# another object, returning:
# - a value less than zero if `self` is less than the other object
# - a value greater than zero if `self` is greater than the other object
# - zero if `self` is equal to the other object
# - a negative number if `self` is less than the other object
# - a positive number if `self` is greater than the other object
# - `0` if `self` is equal to the other object
# - `nil` if `self` and the other object are not comparable
#
# `Comparable` uses `<=>` to implement the conventional comparison operators
Expand All @@ -19,14 +19,14 @@
# methods will perform slightly slower.
module Comparable(T)
# Compares this object to *other* based on the receiver’s `<=>` method,
# returning `true` if it returns a value less than zero.
# returning `true` if it returns a negative number.
def <(other : T)
cmp = self <=> other
cmp ? cmp < 0 : false
end

# Compares this object to *other* based on the receiver’s `<=>` method,
# returning `true` if it returns a value equal or less then zero.
# returning `true` if it returns a value equal or less then `0`.
def <=(other : T)
cmp = self <=> other
cmp ? cmp <= 0 : false
Expand All @@ -50,14 +50,14 @@ module Comparable(T)
end

# Compares this object to *other* based on the receiver’s `<=>` method,
# returning `true` if it returns a value greater then zero.
# returning `true` if it returns a value greater then `0`.
def >(other : T)
cmp = self <=> other
cmp ? cmp > 0 : false
end

# Compares this object to *other* based on the receiver’s `<=>` method,
# returning `true` if it returns a value equal or greater than zero.
# returning `true` if it returns a value equal or greater than `0`.
def >=(other : T)
cmp = self <=> other
cmp ? cmp >= 0 : false
Expand Down

0 comments on commit dc0ba81

Please sign in to comment.