title: How can I get my array to only be manipulated locally (within a function) in Ruby?
body: <p>Why is my array globally manipulated, when I run the below ruby code? And how can I get arrays to be manipulated only within the function's scope?</p>
  
  <pre><code>a = [[1,0],[1,1]]
  
  def hasRowsWithOnlyOnes(array)
    array.map { |row|
      return true if row.keep_if{|i| i != 1 } == []
    }
    false;
  end
  
  puts a.to_s
  puts hasRowsWithOnlyOnes(a)
  puts a.to_s
  </code></pre>
  
  <p><code>$ ruby test.rb</code> output:</p>
  
  <pre><code>[[1, 0], [1, 1]]
  true
  [[0], []]
  </code></pre>
  
  <p>I can't get it to work. I've even tried <code>.select{true}</code> and assign it to a new name. How does the scope work in Ruby for Arrays?
  Just for reference, <code>$ ruby -v</code>:</p>
  
  <pre><code>ruby 2.2.1p85 (2015-02-26 revision 49769) [x86_64-linux]
  </code></pre>