パンくず
Ruby Cookbook
配列の重複要素削除
概要
配列の重複要素削除
サンプル
array = [:one,:two,:three,:two] print array puts print array.uniq #=>不変メソッドで重複要素削除 puts print array puts print array.uniq! #=>破壊的メソッドで重複要素削除 puts print array puts
出力
[:one, :two, :three, :two] [:one, :two, :three] [:one, :two, :three, :two] [:one, :two, :three] [:one, :two, :three]