From: "Peña, Botp" Date: 2007-07-17T16:31:00+09:00 Subject: Re: What is the fastest way to convert a object? From: Magicloud Magiclouds [mailto:magicloud.magiclouds@gmail.com] # Would obj.extend(Test) work? ah, module (instead of class) would be good for morhphing (mixin in ruby's parlance) irb(main):003:0> module Test irb(main):004:1> def methodA irb(main):005:2> puts @var1 irb(main):006:2> end irb(main):007:1> def initialize irb(main):008:2> @var1=0 irb(main):009:2> end irb(main):010:1> end => nil irb(main):011:0> obj=Object.new => # irb(main):012:0> obj.instance_variable_set(:@var1,2) => 2 irb(main):013:0> obj.extend Test => # irb(main):021:0> obj.methods.grep /^method/ => ["method", "methodA", "methods"] irb(main):022:0> obj.methodA 2 => nil kind regards -botp