<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<oembed>
  <author_name>yarb</author_name>
  <author_url>https://blog.hatena.ne.jp/yarb/</author_url>
  <blog_title>yarbの日記</blog_title>
  <blog_url>https://yarb.hatenadiary.org/</blog_url>
  <categories>
    <anon>ruby</anon>
  </categories>
  <description>改めてStruct関連のイディオムについて調べた。Ruby標準のStructクラスを使えばコンストラクタでの面倒な初期化を飛ばせる。以下のクラスBとクラスCは、ほぼ同じ機能を実現する。 class B attr_accessor :var1, :var2 def initialize(var1, var2) @var1, @var2 = var1, var2 end end B.new(&quot;bar&quot;, 5) =&gt; #&lt;B:0x007fae7a93ddb8 @var1=&quot;bar&quot;, @var2=5&gt; class C &lt; Struct.new(:var1, :var2) end C.new(&quot;foo…</description>
  <height>190</height>
  <html>&lt;iframe src=&quot;https://hatenablog-parts.com/embed?url=https%3A%2F%2Fyarb.hatenadiary.org%2Fentry%2F20130104%2Fp1&quot; title=&quot;RubyのStructのイディオムとアンドキュメンテッドな機能 - yarbの日記&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>2013-01-04 00:00:00</published>
  <title>RubyのStructのイディオムとアンドキュメンテッドな機能</title>
  <type>rich</type>
  <url>https://yarb.hatenadiary.org/entry/20130104/p1</url>
  <version>1.0</version>
  <width>100%</width>
</oembed>
