[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

how to delete Array

Giles Bowkett

11/8/2007 4:14:00 AM

This will be possible in Rubinius, but it requires savaging the source
code. Is there a way to do it in normal Ruby? Is source code savagery
required?

--
Giles Bowkett

Blog: http://gilesbowkett.bl...
Portfolio: http://www.gilesg...
Tumblelog: http://giles.t...

4 Answers

ara.t.howard

11/8/2007 4:38:00 AM

0


On Nov 7, 2007, at 9:13 PM, Giles Bowkett wrote:

> This will be possible in Rubinius, but it requires savaging the source
> code. Is there a way to do it in normal Ruby? Is source code savagery
> required?
>
> --
> Giles Bowkett
>
> Blog: http://gilesbowkett.bl...
> Portfolio: http://www.gilesg...
> Tumblelog: http://giles.t...
>

Object.module_eval{ remove_const :Array }

??

a @ http://drawohara.t...
--
it is not enough to be compassionate. you must act.
h.h. the 14th dalai lama




Mikel Lindsaar

11/8/2007 10:18:00 AM

0

heh... "...and thus the gates of hell were thrown open..."

Gotta love that about Ruby... you can even kiss a basic class like
Array goodbye with a single line of code.

I love ruby.

Mikel

On 11/8/07, ara.t.howard <ara.t.howard@gmail.com> wrote:
>
> On Nov 7, 2007, at 9:13 PM, Giles Bowkett wrote:
>
> > This will be possible in Rubinius, but it requires savaging the source
> > code. Is there a way to do it in normal Ruby? Is source code savagery
> > required?
> >
> > --
> > Giles Bowkett
> >
> > Blog: http://gilesbowkett.bl...
> > Portfolio: http://www.gilesg...
> > Tumblelog: http://giles.t...
> >
>
> Object.module_eval{ remove_const :Array }
>
> ??
>
> a @ http://drawohara.t...
> --
> it is not enough to be compassionate. you must act.
> h.h. the 14th dalai lama
>
>
>
>
>

Giles Bowkett

11/8/2007 6:21:00 PM

0

On 11/8/07, Mikel Lindsaar <raasdnil@gmail.com> wrote:
> heh... "...and thus the gates of hell were thrown open..."
>
> Gotta love that about Ruby... you can even kiss a basic class like
> Array goodbye with a single line of code.
>
> I love ruby.

>> Object.module_eval{ remove_const :Array }
=> Array
/opt/local/lib/ruby/1.8/irb/slex.rb:72:in `match': uninitialized
constant IRB::SLex::Array (NameError)

You could probably alias that to :implode.


> Mikel
>
> On 11/8/07, ara.t.howard <ara.t.howard@gmail.com> wrote:
> >
> > On Nov 7, 2007, at 9:13 PM, Giles Bowkett wrote:
> >
> > > This will be possible in Rubinius, but it requires savaging the source
> > > code. Is there a way to do it in normal Ruby? Is source code savagery
> > > required?
> > >
> > > --
> > > Giles Bowkett
> > >
> > > Blog: http://gilesbowkett.bl...
> > > Portfolio: http://www.gilesg...
> > > Tumblelog: http://giles.t...
> > >
> >
> > Object.module_eval{ remove_const :Array }
> >
> > ??
> >
> > a @ http://drawohara.t...
> > --
> > it is not enough to be compassionate. you must act.
> > h.h. the 14th dalai lama
> >
> >
> >
> >
> >
>
>


--
Giles Bowkett

Blog: http://gilesbowkett.bl...
Portfolio: http://www.gilesg...
Tumblelog: http://giles.t...

Arlen Cuss

11/9/2007 10:48:00 AM

0

Hi,

On Fri, 2007-11-09 at 03:21 +0900, Giles Bowkett wrote:
> On 11/8/07, Mikel Lindsaar <raasdnil@gmail.com> wrote:
> > heh... "...and thus the gates of hell were thrown open..."
> >
> > Gotta love that about Ruby... you can even kiss a basic class like
> > Array goodbye with a single line of code.
> >
> > I love ruby.
>
> >> Object.module_eval{ remove_const :Array }
> => Array
> /opt/local/lib/ruby/1.8/irb/slex.rb:72:in `match': uninitialized
> constant IRB::SLex::Array (NameError)
>
> You could probably alias that to :implode.
>

That happens because irb then tries to use an Array internally and it no
longer exists. In normal Ruby interpreted code, it'll work fine so far
as you use no arrays.