title: How to return value from a Ruby function for use in the rest of the program
body: <p>I have written a small ruby function that alters a string variable according to its length.  The printout shows that in the function, the variable is altered -- however it is always reset to its default when it is called later in the program.</p>
  
  <pre><code>#ruby variable test
  
  def mrn_value(mrn_length, mrn)
  if mrn_length &lt; 7 
    case mrn_length
     when 6
         mrn = '0' &lt;&lt; mrn
          return mrn
     when 5
         mrn = '00' + mrn
          return mrn 
     when 4
         mrn = '000' + mrn
         return mrn 
     when 3
      puts mrn
         mrn = '0000' + mrn
         puts mrn
        return mrn 
     when 2
      mrn = mrn.to_s
      puts 'mrn of 2 length'                             #prints 'mrn of 2 length'
         mrn = '00000' + mrn
         puts 'mrn altered in case statement: ' + mrn    #prints 'mrn altered in case statement 0000012'
    when 1
         mrn = '000000' + mrn
          return mrn 
     end
       end 
     end
  
  mrn = 12
  mrn = mrn.to_s
  mrn_length = mrn.length
  
  
  
  mrn_value(mrn_length, mrn)
  puts 'Returned MRN: ' + mrn                             #prints '12'
  </code></pre>
  
  <p>What I need is for the returned MRN to be the altered MRN. thoughts?</p>