{"version":"1.0","width":"100%","title":" Hash.new([]) \u306b\u305f\u307e\u306b\u30cf\u30de\u308b","url":"https://blog.basyura.org/entry/20091201/p2","height":"190","categories":["ruby"],"image_url":null,"provider_name":"Hatena Blog","author_name":"basyura","blog_url":"https://blog.basyura.org/","html":"<iframe src=\"https://hatenablog-parts.com/embed?url=https%3A%2F%2Fblog.basyura.org%2Fentry%2F20091201%2Fp2\" title=\" Hash.new([]) \u306b\u305f\u307e\u306b\u30cf\u30de\u308b - basyura&#39;s blog\" class=\"embed-card embed-blogcard\" scrolling=\"no\" frameborder=\"0\" style=\"display: block; width: 100%; height: 190px; max-width: 500px; margin: 10px 0px;\"></iframe>","type":"rich","blog_title":"basyura's blog","published":"2009-12-01 00:00:01","description":"Array#inject \u3067\u30ad\u30fc\u306b\u5bfe\u3059\u308b\u5024\u3092\u914d\u5217\u3067\u6301\u3064 Hash \u3092\u751f\u6210\u3059\u308b\u969b\u306b\u3001 m = [\"a\",\"a\",\"b\",\"b\"].inject(Hash.new([])){|map,v| map[v] << v.upcase map } p m #=> {} \u3068\u3057\u3061\u3083\u3063\u3066\u8fd4\u3063\u3066\u304d\u305f Hash \u304c\u7a7a\u3067\u305f\u307e\u306b\u30cf\u30de\u308b\u3002 \u30c7\u30d5\u30a9\u30eb\u30c8\u5024\u3068\u3057\u3066\u3001\u6bce\u56de\u540c\u4e00\u306e\u30aa\u30d6\u30b8\u30a7\u30af\u30c8ifnone\u3092\u8fd4\u3057\u307e\u3059\u3002 class Hash \u4e0a\u306e\u4f8b\u3060\u3068 p m.default #=> [\"A\",\"A\",\"B\",\"B\"] \u3068\u306a\u3063\u3066\u3001ifnone \u306b\u5168\u3066\u7a81\u3063\u8fbc\u307e\u308c\u3066\u3057\u307e\u3063\u3066\u3044\u308b\u3002 \u5225\u306b\u521d\u671f\u51e6\u7406\u3092\u304b\u307e\u305b\u3070\u3044\u3044\u3093\u3060\u3051\u3069\u3001\u3053\u308c\u307e\u305f () \u3092\u7701\u7565\u2026","author_url":"https://blog.hatena.ne.jp/basyura/","provider_url":"https://hatena.blog"}