Created
September 5, 2014 02:18
-
-
Save kurotaky/08eef9284ec1c198c2be to your computer and use it in GitHub Desktop.
Ruler
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
# パーフェクトRuby p137 | |
class Ruler | |
attr_accessor :length | |
def initialize(length) | |
self.length = length | |
end | |
def ==(other) | |
length == other.length | |
end | |
end | |
ruler1 = Ruler.new(30) | |
ruler2 = Ruler.new(30) | |
p ruler1 == ruler2 | |
ruler2.length = 40 | |
p ruler1 == ruler2 | |
p ruler1 == 'a' * 30 | |
p ruler1 == 'a' * 31 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment