From: David Garamond Date: 2002-10-09T17:44:24+09:00 Subject: Re: inserting an element to array at a specified position Yukihiro Matsumoto wrote: > |since ruby's array doesn't have index(POS, OBJ) like in python, nor > |splice() like in perl, what is the most common way to insert an element > |at a specified position? > > ary = [0,1,2] > ary[1,0] = "a" # => ary = [0,"a",1,2] hm, that's the ugliest thing i've seen in ruby so far. :-) since ruby already has a rich set of methods for Array, including convenience/"secondary" stuffs like flatten(), indexes(), or rassoc(), wouldn't it make some sense to add insert() too? just a suggestion. (i could add the method myself, of course, but...) -- dave