Re: determining whether an object is an immediate?
- From: Eric Mahurin <eric_mahurin@xxxxxxxxx>
- Date: Mon, 31 Oct 2005 00:57:53 +0900
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
--- Gene Tani <gene.tani@xxxxxxxxx> wrote:
> you think #clone is slow, try (you could test for adding
> singleton
> methods, that would be even slower!):
>
> + x.report("objSpace ") do
> + ITERATIONS.times do
> + OBJECTS.each do |obj|
> + begin
> + if ObjectSpace.include?(obj)
> + # nothin
> + end
> + rescue TypeError
> + # noting
> + end
> + end
> + end
> + end
>
> Timothy Hunter wrote:
> > 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?):
> > >
>
>
>
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
.
- Follow-Ups:
- Re: determining whether an object is an immediate?
- From: Park Heesob
- Re: determining whether an object is an immediate?
- From: Gyoung-Yoon Noh
- Re: determining whether an object is an immediate?
- References:
- Re: determining whether an object is an immediate?
- From: Gene Tani
- Re: determining whether an object is an immediate?
- Prev by Date: Re: Which Ruby Version?
- Next by Date: Re: Regexp Guru Needed
- Previous by thread: Re: determining whether an object is an immediate?
- Next by thread: Re: determining whether an object is an immediate?
- Index(es):
Relevant Pages
|