Remove duplicates from loop

后端 未结 3 1130
醉话见心
醉话见心 2021-01-26 00:57

i have following code.

for i in 0..sold.length-1
    duplicate = sold[i]
    print duplicate.check_duplicates
    print \"     \"
    print sold[i].lotnumber + \         


        
3条回答
  •  执笔经年
    2021-01-26 01:17

    uniq_solds = sold.collect{|s| [s.check_duplicates, s.lotnumber, s.serialnumber]}.uniq
    
    uniq_solds.each do |s|
      p s.join("      ")
    end
    

提交回复
热议问题