08/06/28 22:56:43
mapもcollectもinjectも使いにくそうwクロージャってのがあればいいのかな?
まあメソッド書けばいいんじゃね?だれか採点よろしく
def second_column_uniq(ar)
hash = {}
result = []
ar.each do |row|
t = row.split(/\t/)[1]
puts t
next if hash.has_key?(t)
hash[t] = 1
result.push(row)
end
result
end
ar = ["1\tA\tあ", "2\tB\tい", "3\tA\tう"]
p second_column_uniq(ar)