title: Curly Brackets Within Functions in R
body: <p>I’ve come across functions with the following format x({…}) instead of just x( ). As an example:</p>
  
  <pre><code>suppressWarnings({ yahoo_answer &lt;- tryCatch({ getSymbols(ticker, src ="yahoo")
   }, error = function(err) { NA }) })
  </code></pre>
  
  <p>Here suppressWarnings is a function, but inside of it is code enclosed by curly brackets.  </p>
  
  <p>What is the purpose of the curly brackets within functions? I have an idea of how and why it works here for tryCatch in particular, but I don’t know enough to generalize this and put this into my own code in other applications. Can anyone help me understand how and when you would use this kind of structure?</p>
  
  <p>this answer in stackoverflow kind of touches on it:</p>
  
  <p><a href="https://stackoverflow.com/questions/12193779/how-to-write-trycatch-in-r/12195574#12195574">How to write trycatch in R</a></p>
  
  <p>I also posted this on another forum, but no luck. </p>