{"categories":["Ruby"],"blog_url":"https://ml-rand-note.hatenablog.com/","provider_url":"https://hatena.blog","width":"100%","html":"<iframe src=\"https://hatenablog-parts.com/embed?url=https%3A%2F%2Fml-rand-note.hatenablog.com%2Fentry%2Fruby%2Farray-uniq-compact-select\" title=\"\u3010Ruby\u3011\u914d\u5217 \u524a\u9664\u30fb\u62bd\u51fa\u30e1\u30bd\u30c3\u30c9\u307e\u3068\u3081(uniq, compact, select, filter) - \u30e9\u30f3\u30c9ML\" class=\"embed-card embed-blogcard\" scrolling=\"no\" frameborder=\"0\" style=\"display: block; width: 100%; height: 190px; max-width: 500px; margin: 10px 0px;\"></iframe>","title":"\u3010Ruby\u3011\u914d\u5217 \u524a\u9664\u30fb\u62bd\u51fa\u30e1\u30bd\u30c3\u30c9\u307e\u3068\u3081(uniq, compact, select, filter)","author_url":"https://blog.hatena.ne.jp/round-rand/","type":"rich","url":"https://ml-rand-note.hatenablog.com/entry/ruby/array-uniq-compact-select","image_url":null,"author_name":"round-rand","published":"2026-07-02 00:00:00","blog_title":"\u30e9\u30f3\u30c9ML","height":"190","provider_name":"Hatena Blog","description":"uniq\uff1a\u91cd\u8907\u3057\u305f\u8981\u7d20\u3092\u9664\u53bb\u3057\u305f\u914d\u5217\u3092\u4f5c\u6210 compact\uff1anil\u3092\u524a\u9664\u3057\u305f\u914d\u5217\u3092\u4f5c\u6210 select(filter)\uff1a\u6761\u4ef6\u3092\u6e80\u305f\u3059\u8981\u7d20\u3092\u62bd\u51fa \u53c2\u8003 uniq\uff1a\u91cd\u8907\u3057\u305f\u8981\u7d20\u3092\u9664\u53bb\u3057\u305f\u914d\u5217\u3092\u4f5c\u6210 uniq\u306f\u91cd\u8907\u3057\u305f\u8981\u7d20\u3092\u9664\u53bb\u3057\u305f\u914d\u5217\u3092\u8fd4\u3057\u307e\u3059\u3002 uniq!\u306a\u3089\u7834\u58ca\u7684\u306b\u9664\u53bb\u3092\u3057\u3001 \u524a\u9664\u3042\u308a \u21d2 \u914d\u5217 \u524a\u9664\u306a\u3057 \u21d2 nil \u3092\u8fd4\u3057\u307e\u3059\u3002 ary = [1, 3, 2, 2, 3] # uniq\u306f\u5143\u306e\u914d\u5217\u306f\u305d\u306e\u307e\u307e p ary.uniq #=> [1, 3, 2] p ary #=> [1, 3, 2] # uniq!\u306f\u5143\u306e\u914d\u5217\u3092\u66f4\u65b0(\u7834\u58ca\u7684) p ary.uniq! #=> [1, 3, 2] p a\u2026","version":"1.0"}