title: How to write a function that takes a closure of a view and returns a view?
body: <p>I'm wanting to write utilities that work with views to do things like conditionally show views and do things like <code>intersperse</code> where a view is repeated and some kind of separator is inserted between each iteration.  I can't figure out how to define the function type signature.  This is what I got so far:</p>
  <pre class="lang-swift prettyprint-override"><code>    func ifNotLastCategory(_ cat: String, content: () -&gt; AnyView) -&gt; AnyView {
          if (cat != movie.categories.last) { return content() }
      }
  
  
      ...
      
      ifNotLastCategory(category) { Text(&quot;Hello World&quot;) }
  
  </code></pre>
  <p>When I try to do something like that I get a compiler error about <code>Cannot convert value of type 'some View' to closure result type 'AnyView'</code>.  However it won't let me define <code>content</code> as returning <code>some View</code>.</p>
  <p>How can I make this function work?</p>