title: Swift function with a function as parameter
body: <p>I have a question about why I get a compilation error of "Missing return in a function". I am following the examples in the "The Swift Programming Language" book and there is a section about passing a function as a parameter of another function.</p>
  
  <p>Here is the book's example which compiles fine:</p>
  
  <pre><code>func hasAnyMatches(list: [Int], condition: Int -&gt; Bool) -&gt; Bool {
      for item in list {
          if condition (item) {// anonymous function call
              return true
          }
      }
      return false
  }
  
  func lessThanTen(number: Int) -&gt; Bool {
      return number &lt; 10
  }
  </code></pre>
  
  <p>I understand this, but I thought I could make a subtle change, because I felt the if condition(item){ } was redundant.
  Here is my alteration:</p>
  
  <pre><code>func hasAnyMatches(list: [Int], condition: Int -&gt; Bool) -&gt; Bool {
      for item in list {
          return condition(item)
      }//error here with "Missing return in a function expected  to return bool"
  }
  </code></pre>
  
  <p>I'm returning a bool because I return the result of the function. There is no case where I would not return a bool during the for-in loop.</p>
  
  <p>I don't understand why this does not compile, could someone explain why?</p>