From: John Tromp Date: 2002-09-20T01:20:35+09:00 Subject: subclassing Integer I'm writing a state space search program where each state can be consisely described by an Integer. I need these states to have several new methods. I can either 1) create a new class with an Integer attribute or 2) try to subclass Integer or 3) pass around Integers to methods of another class Option 2) appears to be possible, but perhaps useless, as I cannot seem to generate objects of the new type: class State < Integer def initialize(n) super(n) end end a=State.new(5) # -> undefined method `new' for State:Class (NameError) The only reason I would try option 2) is that I expect to have 100s of millions of these States around, and like 3) it might save memory. Does anyone know if option 1) will take more memory than option 3) and if anything like option 2) can combine their advantages? regards, %!PS % -John Tromp (http://www.cwi.nl/~tromp/) 42 42 scale 7 9 translate .07 setlinewidth .5 setgray/c{arc clip fill setgray}def 1 0 0 42 1 0 c 0 1 1{0 3 3 90 270 arc 0 0 6 0 -3 3 90 270 arcn 270 90 c -2 2 4{-6 moveto 0 12 rlineto}for -5 2 5{-3 exch moveto 9 0 rlineto}for stroke 0 0 3 1 1 0 c 180 rotate initclip}for showpage