title: How to add a method to an existing object instance at runtime in Ruby?
body: <p>In Javascript I could do this.</p>
  
  <pre><code>var a = {};
  a.f1 = function(){};
  </code></pre>
  
  <p>How can I do this in Ruby?</p>
  
  <hr>
  
  <p>Update.</p>
  
  <p>In JS code, <code>a</code> is an object instantiated without class. And <code>function(){}</code> is an anonymous function, and <code>a.f1 =</code> adds the function to the object instance. So the function is bound to the instance only, and nothing is related to the class or similar definitions.</p>