{"type":"rich","published":"2026-06-10 00:00:00","provider_name":"Hatena Blog","description":"partition\u30e1\u30bd\u30c3\u30c9\u3068\u306f\uff1f \u6761\u4ef6\u3092\u6e80\u305f\u3059\u8981\u7d20\u3068\u6e80\u305f\u3055\u306a\u3044\u8981\u7d20\u3092\u540c\u6642\u306b\u53d6\u5f97\u3067\u304d\u308b\u30e1\u30bd\u30c3\u30c9\u3067\u3059\u3002 \u6761\u4ef6\u3092\u6e80\u305f\u3059 or \u6e80\u305f\u3055\u306a\u3044\u8981\u7d20\u306e\u307f\u3092\u53d6\u5f97\u3057\u305f\u3044\u5834\u5408\u306fselect\u3084reject\u3067\u53d6\u5f97\u3067\u304d\u307e\u3059\u304c\u3001\u3069\u3061\u3089\u3082\u53d6\u5f97\u3057\u305f\u3044\u5834\u5408\u306b\u306fpartition\u3092\u4f7f\u3044\u307e\u3059\u3002 \u6761\u4ef6\u3092\u6e80\u305f\u3059\u914d\u5217, \u6761\u4ef6\u3092\u6e80\u305f\u3055\u306a\u3044\u914d\u5217 = \u914d\u5217.partition { |item| \u6761\u4ef6 } partition\u306e\u4f7f\u7528\u4f8b1\uff1a\u5076\u6570\u3068\u5947\u6570\u306b\u5206\u3051\u308b ary = [1, 2, 3, 4, 5, 6] evens, odds = ary.partition(&:even?) p evens #=> [2, 4, 6] p odds #=> [\u2026","version":"1.0","title":"\u3010Ruby\u3011partition\u306e\u4f7f\u3044\u65b9","height":"190","blog_title":"\u30e9\u30f3\u30c9ML","image_url":null,"url":"https://ml-rand-note.hatenablog.com/entry/ruby/partition","html":"<iframe src=\"https://hatenablog-parts.com/embed?url=https%3A%2F%2Fml-rand-note.hatenablog.com%2Fentry%2Fruby%2Fpartition\" title=\"\u3010Ruby\u3011partition\u306e\u4f7f\u3044\u65b9 - \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>","categories":["Ruby"],"provider_url":"https://hatena.blog","width":"100%","author_url":"https://blog.hatena.ne.jp/round-rand/","blog_url":"https://ml-rand-note.hatenablog.com/","author_name":"round-rand"}