From: Hugh Sasse Staff Elec Eng Date: 2001-03-22T02:17:51+09:00 Subject: [ruby-talk:13039] extending existing classes. I've run up against something I thought I knew how to solve, but... class IO def outputbit(bit) @c = (@c << 1) | bit @bitcount += 1 if ((@bitcount % 8) == 0) putc(c) c = 0 end end end OK, horribly inefficient, but still. I have extended IO. Now, how do I get IO to initialize @c and @bitcount properly? Do I class IO rename :initialize :orig_initialize def initialize(*args) @c = 0 @bitcount = 0 old_initialize(args) end end and will this be picked up by open and so on, or do I do something else? And should the solution go in the CodingInRuby on the Wiki? Hugh