{"published":"2020-05-03 18:10:20","type":"rich","image_url":null,"author_name":"obelisk2","width":"100%","provider_url":"https://hatena.blog","blog_url":"https://obelisk.hatenablog.com/","provider_name":"Hatena Blog","categories":["Ruby"],"html":"<iframe src=\"https://hatenablog-parts.com/embed?url=https%3A%2F%2Fobelisk.hatenablog.com%2Fentry%2F2020%2F05%2F03%2F181020\" title=\"inject \u304c Enumerator \u3092\u8fd4\u3055\u306a\u3044\uff08Ruby\uff09 - Camera Obscura\" class=\"embed-card embed-blogcard\" scrolling=\"no\" frameborder=\"0\" style=\"display: block; width: 100%; height: 190px; max-width: 500px; margin: 10px 0px;\"></iframe>","height":"190","title":"inject \u304c Enumerator \u3092\u8fd4\u3055\u306a\u3044\uff08Ruby\uff09","url":"https://obelisk.hatenablog.com/entry/2020/05/03/181020","blog_title":"Camera Obscura","description":"\u4f8b\u3048\u3070 true/false \u306e\u914d\u5217\u3092\u30d3\u30c3\u30c8\u5217\u306b\u5909\u63db\u3057\u305f\u3044\u3068\u3057\u3066\u3001\u3053\u3046\u3057\u305f\u304b\u3063\u305f\u3002 cond = [true, false, false, true, false, true] cond.inject(0).with_index {|(acc, c), i| c ? acc | 1 << i : acc} #=>TypeError (0 is not a symbol nor a string) inject\u306f\u30d6\u30ed\u30c3\u30af\u3092\u53d6\u3089\u306a\u3044\u5834\u5408\u3001Enumerator \u3092\u8fd4\u3055\u306a\u3044\u306e\u3067\u3059\u306d\u3002 \u4ed5\u65b9\u304c\u306a\u3044\u306e\u3067enum_for\u3092\u4f7f\u3046\u3002 cond.enum_for(:inject, 0).with_index {|\u2026","version":"1.0","author_url":"https://blog.hatena.ne.jp/obelisk2/"}