Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require "set"
- class Word
- def initialize(text)
- @value = text
- end
- def value
- return @value
- end
- def <=>(text)
- puts 'comapring'
- return text<=>@value
- end
- def eql?(other)
- if (@value <=> other.value) == 0
- puts 'checking'
- return true
- else
- return false
- end
- end
- end
- class Vocab
- @list
- def initialize
- @list = SortedSet.new
- end
- def add(newWord)
- @list.add(newWord)
- end
- def printit
- return @list
- end
- end
- a = Word.new('a')
- b = Word.new('b')
- b2= Word.new('b')
- glossary = Vocab.new
- glossary.add(b)
- glossary.add(a)
- glossary.add(b2)
- puts glossary.printit.inspect
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement