title: Ruby Object Initialize with Optional Arguments
body: <p>How can I code an initalizer() method to form instance variables (empty or otherwise), then iterate through a set of args to set instance variables?</p>
  
  <p>This is what I am thinking:</p>
  
  <pre><code>def initialize(*p)
    @sid                      = "123asdf654"
    @token                    = "abc123"
    @bert                     = "1192875119"
    @me                       = "4165551212"
    @media_url                = ""
    @message                  = ""
  
    args.each do |k,v|
      instance_variable_set("@#{k}", v) unless v.nil?
    end
  end
  </code></pre>
  
  <p>I want to have the ability to set known instance variables (shown here), then iterate through args and either update the values of chosen instance variables, or create new ones.  </p>