title: How to return a Button from a function in SwiftUI?
body: <p>I need to dynamically create a Button based on some parameters</p>
  
  <pre class="lang-swift prettyprint-override"><code>func buildButton(parameter : Parameter) -&gt; Button {
          switch (parameter){
              case Parameter.Value1:
                  return Button(
                      action: {
                          ...
                  },
                      label: {
                          ...
                  }
              )
              case Parameter.Value2:
                  return Button(
                      action: {...},
                      label: {
                          ...
                  }
              )
          }
      }
  </code></pre>
  
  <p>But the compiler gives me this error:</p>
  
  <blockquote>
    <p>Reference to generic type 'Button' requires arguments in &lt;...>. Insert '&lt;&lt;#Label: View#>>'</p>
  </blockquote>
  
  <p>So if I click <code>Fix</code>, the function declaration becomes</p>
  
  <pre class="lang-swift prettyprint-override"><code>func buildButton(parameter : Parameter) -&gt; Button&lt;Label:View&gt;
  </code></pre>
  
  <p>and the compiler gives </p>
  
  <blockquote>
    <p>Use of undeclared type '&lt;#Label: View#>'</p>
  </blockquote>
  
  <p>What do I need to insert here to be able to return a <code>Button</code>?</p>