From: Clemens Hintze Date: 2000-02-15T00:33:48+01:00 Subject: [ruby-talk:01347] Say Hi mengx@nielsenmedia.com writes: > Hi: Hi too, may I take this opportunity to welcome you here? It is fine to see, how fast the Ruby community seems to grow :-) > I Studied Ruby's document and coding for about two days and decided > to start using Ruby even though I have used Python for 5 years, > among other languages. In my opinion, Ruby is what Python 3000 > should be if all these $$$$ can be removed :-) (for some reason, I > never like $$$$ so I chose Python (also due to neat syntax) over > Perl). Ruby is ultimate dynamic language. You have nearly the same background like me! I am also coming from Perl->Python->Ruby! And I have to recognize ever and ever again *how* dynamically Ruby is, indeed. After a year of usage, there are still some facts that surprise me yet! :-) > Just a quick thought after going through Array class, would it be > possible to revise the pop and push method to accept index argument > such that pop(0) act like shift and pop(-1) like current pop push > (obj, 0) like unshift and push(obj, -1) like current push. shift > and unshift are too Perlitical :-). I know I can subclass it, but > having it builtin would be better. > I beg pardon, but I would not like it! I think it is not too good to have too multifunctional methods. Every method should has its behavior. push and pop are used to handle an Array like a stack not for indexing it. shift and unshift do the same but from the opposite end. They are not necessarily coming from Perl. Nearly all UNIX shells treat them like Perl. I assume Perl has taken that behavior from the UNIX shells. IMHO, it would be better to allow Array::delete_at to receive also negative arguments like Array::[]. If it would do, it would really be what you want to have. Then you could use: arr = [9,8,7,6] first = arr.delete_at(0) # first element assigned and deleted last = arr.delete_at(-1) # last element now. p arr # would print [8,7] What do you think about it? > Thanks > > -Ted Meng \cle -- Clemens Hintze mailto: c.hintze@gmx.net