Handling second demensional array
Submitted by yas on Thu, 10/18/2007 - 09:28.
Hi all devils!!
How are you.
Yas is reactivated finally :)
Today I tried some tricky situation.
I needed to compact second dimensional array, which includes some id's and other elements.
Using id and detect the target elements and remove them.
Oh my English is getting worse day by day...
But I believe code talks everything instead of me :)
Ok today's small piece of Ruby code is following
#Compact the second demencional array arr = [[0,"miyake","password"],[1,"miyake","hoge"],[2,"hoge","hoge"]] @target = 0 arr.each {|a| if a[0] == @target arr[@target] = nil end } p arr.compact
Enjoy if you have some comment or any more great idea!!
Please share with us! Thanks from Japan!
yas's blog
• Login or register to post comments

