ruby on rails 数组去重

@information = ['1','1','1','2','2','2','3','3','3','4','5','6','6','6','7','7','8','8','8']

@information.each do |info|

    array = [] 

    array << info          

    @information = @information - array

    @information << info

end


# =>  ["1", "2", "3", "4", "5", "6", "7", "8"]



当然 @information.uniq 也一样。


如果解决问题了点个赞哈~



你可能感兴趣的:(ruby on rails 数组去重)