lib/core/facets/comparable/cmp.rb in facets-2.8.4 vs lib/core/facets/comparable/cmp.rb in facets-2.9.0.pre.1

- old
+ new

@@ -12,10 +12,11 @@ # CREDIT: Peter Vanbroekhoven def cmp(o) self<=>o end + end class String # Compare method that takes length into account. @@ -25,9 +26,11 @@ # "abcd".cmp("abc") #=> 1 # "abc".cmp("abcd") #=> -1 # "xyz".cmp("abc") #=> 1 # # CREDIT: Peter Vanbroekhoven + # + # TODO: Move String#cmp to string/ directory. def cmp(other) return -1 if length < other.length return 1 if length > other.length self <=> other # alphabetic compare