title: Setting Attributes using Hash in RUby
body: <p>I'm currently completely stuck on a school problem and figured I'd reach out for some guidance.</p>
  
  <p>Define a class named User. Its initialize method should take a Hash as an argument. We'll name the argument config and set a default value for the argument to an empty Hash:</p>
  
  <pre><code>class User
    def initialize(config = {})
    end
  end
  </code></pre>
  
  <p>This <code>config = {}</code> the syntax supplies a "default argument" for initialize. If someone initializes a User instance without a config argument, the config variable in the method will automatically be set to the default we gave it--an empty Hash.</p>
  
  <p>The config argument should be used to set any of the following attributes on a user: <code>name</code>, <code>email</code>, <code>bio</code>, <code>age</code>, and <code>sex</code>. If an attribute is not provided in the Hash argument, the initialize method should default it to a value to "n/a". For example:</p>
  
  <pre><code>class User
    def initialize(config = {})
      @name = config[:name] || "n/a"
      @email = config[:email] || "n/a"
      ...
    end
  end
  </code></pre>
  
  <p>Setting default values is a very common task in Ruby. A basic way to do this is by using the <code>||</code> assignment operator, which means "or". Consider the following examples:</p>
  
  <pre><code>a = 3
  a = a || 6
  a #=&gt; 3
  b = b || 9
  b #=&gt; 9
  </code></pre>
  
  <p>Decode the logic in the conditional assignments above.</p>
  
  <p>We'll also need to access the instance variables set in our initialize method. To do this, we can use the <code>attr_accessor</code> method declaration. The <code>attr_accessor</code> method also lets us declare multiple attributes on one line. For example:</p>
  
  <pre><code>class User
    attr_accessor :name, :email
  
    def initialize(config = {})
      @name = config[:name] || "n/a"
      @email = config[:email] || "n/a"
      # ...
    end
  end
  </code></pre>
  
  <p>Finish writing the <code>User</code> class and <code>initialize</code> method to handle all of the required attributes.</p>
  
  <p>I am entirely lost at this point. Thanks in advance.</p>