title: Is there a way to initialize an object through a hash?
body: <p>If I have this class:</p>
  
  <pre><code>class A
    attr_accessor :b,:c,:d
  end
  </code></pre>
  
  <p>and this code:</p>
  
  <pre><code>a = A.new
  h = {"b"=&gt;10,"c"=&gt;20,"d"=&gt;30}
  </code></pre>
  
  <p>is it possible to initialize the object directly from the hash, without me needing to go over each pair and call <code>instance_variable_set</code>? Something like:</p>
  
  <pre><code>a = A.new(h)
  </code></pre>
  
  <p>which should cause each instance variable to be initialized to the one that has the same name in the hash.</p>