title: Creating a method to modify elements in an array in Ruby with 2 arguments, one of them being the original array
body: <p>I would like to create a method, <code>mod_method(array, n)</code> , where <code>array</code> is an array and <code>n</code> is a number. <code>mod_method</code> should take number <code>n</code> and add it to all internal numbers in <code>array</code> and return that new array.</p>
  
  <p>For example, using <code>array = ["I", "have", 3, "to", 4, "hours"]</code>, how would I find <code>mod_method(array, 1)</code> such that </p>
  
  <pre><code>mod_method(array,1)
   =&gt; ["I", "have", 4, "to", 5, "hours"]
  </code></pre>
  
  <p>I'm a noob and was only able to do this using the already defined array and number (let's use 1), as such:</p>
  
  <pre><code>array = ["I", "have", 3, "to", 4, "hours"]
  =&gt;[[0] "I",
    [1] "have",
    [2] 3,
    [3] "to",
    [4] 4,
    [5] "hours"]
  
  numbers = array.values_at(2, 4)
  =&gt; [
    [0] 3,
    [1] 4
  
  mod = numbers.map{|x| x + 1}
  =&gt; [
    [0] 4,
    [1] 5]
  new_array = ["I", "have", mod[0], "to", mod[1], "hours"]
  =&gt; ["I", "have", 4, "to", 5, "hours"]
  </code></pre>
  
  <p>I have no idea how to do it with undefined arguments for the <code>mod_method</code>.</p>