<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<oembed>
  <author_name>tkng</author_name>
  <author_url>https://blog.hatena.ne.jp/tkng/</author_url>
  <blog_title>射撃しつつ前転 改</blog_title>
  <blog_url>https://tkng.hatenablog.com/</blog_url>
  <categories>
    <anon>ruby</anon>
  </categories>
  <description>Pythonのハッシュテーブル（Pythonではdictと言いますね）には、初期値が設定できる亜種としてdefaultdictというものがある。Rubyの場合、Hashクラスには初期値が設定できるが、初期値としては整数か文字列、シンボルぐらいしか使えない。初期値として配列とかハッシュテーブルを使えないのである。 そこで、Pythonのdefaultdictっぽいものを作ってみた。以下にコードを示す。 class DefaultHash &lt; Hash def initialize(init) @init = init end def [](k) v = super k if v v else s…</description>
  <height>190</height>
  <html>&lt;iframe src=&quot;https://hatenablog-parts.com/embed?url=https%3A%2F%2Ftkng.hatenablog.com%2Fentry%2F20120522%2F1337621982&quot; title=&quot;rubyでpythonのdefaultdictっぽいものを実現する - 射撃しつつ前転 改&quot; class=&quot;embed-card embed-blogcard&quot; scrolling=&quot;no&quot; frameborder=&quot;0&quot; style=&quot;display: block; width: 100%; height: 190px; max-width: 500px; margin: 10px 0px;&quot;&gt;&lt;/iframe&gt;</html>
  <image_url></image_url>
  <provider_name>Hatena Blog</provider_name>
  <provider_url>https://hatena.blog</provider_url>
  <published>2012-05-22 02:39:42</published>
  <title>rubyでpythonのdefaultdictっぽいものを実現する</title>
  <type>rich</type>
  <url>https://tkng.hatenablog.com/entry/20120522/1337621982</url>
  <version>1.0</version>
  <width>100%</width>
</oembed>
