Remove duplicates from loop

后端 未结 3 1137
醉话见心
醉话见心 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:20

    You can try using something called uniq!, here is a link to the API.

    http://www.ruby-doc.org/core-2.0.0/Array.html#method-i-uniq-21


提交回复
热议问题