title: My function is unable to find an object that I am assigning a value beforehand
body: <p>I wrote the following function, which includes two other functions that I already wrote. </p>
  
  <pre><code>play &lt;- function(){
    got_symbols &lt;- get_symbols()
    print(got_symbols)
    score()
  }
  </code></pre>
  
  <p>When I run play() it messages me with "Error, in "unique(got_symbols)", object got_symbols not found". I wrote score() such that it doesn't take any arguments, but uses got_symbols in its body (I don't think it's content matter but I'll show it to you guys just in case).</p>
  
  <pre><code>score &lt;- function(){
    if ( length(unique(got_symbols)) == 1 ) {
      prize &lt;- prizes_triple[[unique(got_symbols)]]
    } else {
      if (all(got_symbols %in% c("BBB", "BB", "B"))){
        prize &lt;- 5
      } else {
        C_count &lt;- as.character(sum( got_symbols == "C" ))
        prize &lt;- C_prizes[[C_count]]
      }
    }
    DD_count &lt;- sum( got_symbols == "DD")
    prize*(2^DD_count)
  }
  </code></pre>
  
  <p>I don't understand why this happens, when I run play() it runs its code until it calls score(), which should search for got_symbols, but since it doesn't have it in its environment, it should go one up, and it should find the got_symbols that I previously assigned the value of get_symbols(), shouldn't it?
  Now, when I put got_symbols as an argument in score(), it works just fine, but I don't understand what's the difference. I'll appreciate if someone can help me out with that.</p>