From: Brian Mitchell Date: 2005-10-31T15:54:02+09:00 Subject: Re: determining whether an object is an immediate? On 10/29/05, Eric Mahurin wrote: > This is be best I could come up with for determining whether an > object is an immediate (Fixnum, Symbol, false, true, nil, > others?): > > begin > obj.clone > # clone worked - not an immediate > rescue TypeError > # clone failed - immediate > end > > Anybody have a better way? If the above is the best, seems > like an Object#immediate? would be nice to have. > The clone test does not work. Reason? There are plenty of non-immediate objects that won't clone like Float and Bignum instances. One test you could use is the singleton class: # Should raise a TypeError class << :immediate_object; end Of course immediate object could also be found missing from ObjectSpace, but I would imagine that test to be very slow. May I ask why you need to know the immediacy of an object? Brian.