title: Ruby: I need help understanding the following code involving method_missing(method, *args, &block)
body: <p>I came across this code while trying to learn about creating your own method_missing method, and I don't understand it.
  What I don't understand are these parts: method_sym[-1] == "=" and method_sym[0..-2]
  What do they refer to? I tried some simulations in irb, but this just returned some weird stuff.</p>
  
  <p>Could anyone break it down for me? I would really appreciate it. Thanks!</p>
  
  <pre><code>class UberHash
    def method_missing(method_sym, *args, &amp;block)
      if method_sym[-1] == "="
        instance_variable_set("@#{method_sym[0..-2]}", args[0])
      else
        instance_variable_get("@#{method_sym}")
      end
    end
  end
  </code></pre>