title: Break out of a function quietly and no-debug using if statement (or anything else)
body: <h3>Is it possible to break out of a function quietly and no-debug using <code>if</code> statement (or anything else)?</h3>
  <h5>Purpose: I would like to escape from a function (like the break statement in <code>for</code> loop) if specific conditions were met. The function is expected to be utilized in the similar way as <code>mean()</code> (for example) and sometimes within <em>dplyr</em> manipulation and <code>for</code> loop. Besides, I wish to avoid complex nested <code>if-else</code> statement.</h5>
  <pre><code>v &lt;- c(1, 2, 5, 1, 2)
  
  break5 &lt;- function(x){
      # If this exception occur, then
      # end up (escape ?) the whole function
      if (x == 5){
          # next      # &lt;-- This will raise error message
          break     # &lt;-- This will raise error message
          # stop()  # &lt;-- This will raise debugging event
      } 
      
      # Otherwise, proceed the subsequent process
      if (x == 1) print(1)
      if (x == 2) print(2)
  }
  </code></pre>
  <h4>Console Output:</h4>
  <pre><code>&gt; break5(1)
  [1] 1
  
  &gt; break5(2)
  [1] 2
  
  &gt; break5(5)
  Error in break5(5) : no loop for break/next, jumping to top level
  </code></pre>
  <h2>Expect to get silent result as the <code>break</code> in <code>for</code> loop</h2>
  <pre><code>for (i in v){
      if (i == 5) break # &lt;-- Similar with this procedure that 
                        #     could be included in the function
      break5(i)
  }
  </code></pre>
  <h4>Example 1</h4>
  <pre><code>x0 &lt;- 1:100
  y0 &lt;- 1:100
  
  example &lt;- function(x = NULL, y = NULL){
    
    if (is.null(x) | is.null(y)){    
      break                            # Case 1
    }
    
    if (!(x %in% x0) | !(y %in% y0)){
      break                            # Case 2
    }
    
    if (x &lt; 2){
      z &lt;- 1                           # Case 3
      return(z)
    }
    
    if ((x &gt;= 80) &amp; (x &lt;= 100)){
      break                            # Case 4
    }
    
    z &lt;- x + y                        # Otherwise
    return(z)
  }
  
  example(1)    # Case 1, this should be muted
  example(30, 999)    # Case 2, this should be muted
  example(1, 1)    # Case 3, this is OK
  example(80, 1)    # Case 4, this should be muted
  example(11, 1)    # Otherwise, this is OK
  </code></pre>
  <h4>Example 2:</h4>
  <pre><code>for (i in 75:90){
    print(paste0(i, '+', i, '=', example(i, i)))  # The rest should be muted
  }
  </code></pre>