Advertisement
Guest User

Untitled

a guest
Dec 2nd, 2011
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. require "set"
  2.  
  3. class Word
  4.  
  5. def initialize(text)
  6. @value = text
  7. end
  8.  
  9. def value
  10. return @value
  11. end
  12.  
  13. def <=>(text)
  14. puts 'comapring'
  15. return text<=>@value
  16. end
  17.  
  18. def eql?(other)
  19. if (@value <=> other.value) == 0
  20. puts 'checking'
  21. return true
  22. else
  23. return false
  24. end
  25. end
  26.  
  27. end
  28.  
  29. class Vocab
  30.  
  31. @list
  32.  
  33. def initialize
  34. @list = SortedSet.new
  35. end
  36.  
  37. def add(newWord)
  38. @list.add(newWord)
  39. end
  40.  
  41. def printit
  42. return @list
  43. end
  44.  
  45. end
  46.  
  47. a = Word.new('a')
  48. b = Word.new('b')
  49. b2= Word.new('b')
  50.  
  51. glossary = Vocab.new
  52. glossary.add(b)
  53. glossary.add(a)
  54. glossary.add(b2)
  55.  
  56. puts glossary.printit.inspect
  57.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement