Rubyã§éè¤ããå¤ãæé¤ãããå ´åã¯ãuniqã¡ã½ããã使ãã°OKã a = [1, 2, 3, 4, 5, 6, 5, 4] a.uniq #=> [1, 2, 3, 4, 5, 6] éè¤ãã¦ããå¤ããããã©ããã調ã¹ããªããuniqãå©ç¨ããã°ç°¡åã«ãããã a = [1, 2, 3, 4, 5, 6, 5, 4] a.size == a.uniq.size #=> false ã§ããé åããéè¤ãã¦ããå¤ãæ½åºããã¡ã½ããã¯è¦å½ãããªãï¼ãã¶ãï¼ã ããã§ãé åããéè¤ãã¦ããå¤ãæ½åºããã¹ã¯ãªãããæ¸ãã¦ã¿ãã é åããéè¤ãã¦ããå¤ãæ½åºãã a = [1, 2, 3, 4, 5, 6, 5, 4] a.uniq.map{|v| v if a.inject(Hash.new(0)) {|h, key| h[key] += 1; h}[v] >= 2}.compact #=>
{{#tags}}- {{label}}
{{/tags}}