You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[12] pry(main)>$ComparableError:Couldn't locate a definition for Comparable!
[16] pry(main)>YARD::Registry.at('Comparable').docstring
=> "The <code>Comparable</code> mixin is used by classes whose objects\nmay be ordered. The class must define the <code><=></code> operator,\nwhich compares the receiver against another object, returning -1, 0,\nor +1 depending on whether the receiver is less than, equal to, or\ngreater than the other object. If the other object is not comparable\nthen the <code><=></code> operator should return nil.\n<code>Comparable</code> uses\n<code><=></code> to implement the conventional comparison operators\n(<code><</code>, <code><=</code>, <code>==</code>, <code>>=</code>,\nand <code>></code>) and the method <code>between?</code>.\n\n class SizeMatters\n include Comparable\n attr :str\n def <=>(anOther)\n str.size <=> anOther.str.size\n end\n def initialize(str)\n @str = str\n end\n def inspect\n @str\n end\n end\n\n s1 = SizeMatters.new(\"Z\")\n s2 = SizeMatters.new(\"YY\")\n s3 = SizeMatters.new(\"XXX\")\n s4 = SizeMatters.new(\"WWWW\")\n s5 = SizeMatters.new(\"VVVVV\")\n\n s1 < s2 #=> true\n s4.between?(s1, s3) #=> false\n s4.between?(s3, s5) #=> true\n [ s3, s2, s5, s4, s1 ].sort #=> [Z, YY, XXX, WWWW, VVVVV]"
[17] pry(main)>
[17] pry(main)> pry-version
Pry version: 0.10.1 on Ruby 2.2.0.
The text was updated successfully, but these errors were encountered:
The text was updated successfully, but these errors were encountered: