Nic Lin's Blog

喜歡在地上滾的工程師

如何處理陣列裡有重複的值

有時候會遇到倒出來的資料,可能有相同的值,但希望能把重複的值刪掉,只留下個別的值,那可以用uniq這個方法。

螢幕快照 2016-06-07 下午3.33.30.png

array = array.uniq

參考來源 http://stackoverflow.com/questions/5354850/how-do-i-match-two-arrays-with-duplicates-in-ruby

comments powered by Disqus