Created
March 22, 2018 15:17
-
-
Save sevperez/3f845b07cf6089c5c84f55811cbf65c4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Lion | |
| include Comparable | |
| attr_reader :name, :age, :weight, :height, :bravery | |
| def initialize(name, age, weight, height, bravery) | |
| @name = name | |
| @age = age | |
| @weight = weight | |
| @height = height | |
| @bravery = bravery | |
| end | |
| def <=>(other_lion) | |
| self.bravery <=> other_lion.bravery | |
| end | |
| end | |
| simba = Lion.new(“Simba”, 10, 37, 60, 99) | |
| scar = Lion.new(“Scar”, 42, 190, 128, 72) | |
| puts simba > scar # => true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment