From: Gyoung-Yoon Noh Date: 2005-10-31T11:30:30+09:00 Subject: Re: determining whether an object is an immediate? On 10/31/05, Eric Mahurin wrote: > It is slow, but this is probably one of the better definitions > of what an immediate is - whether it exists in ObjectSpace or > not. > > Here's another solution: > > class Object; def immediate?;false;end;end > class Fixnum; def immediate?;true; end;end > class Symbol; def immediate?;true; end;end > class NilClass; def immediate?;true; end;end > class FalseClass;def immediate?;true; end;end > class TrueClass; def immediate?;true; end;end > Here is one-line version: [Object, Fixnum, Symbol, NilClass, FalseClass, TrueClass].each { |c| c.instance_eval { define_method(:immediate?) { true } } } -- http://nohmad.sub-port.net