title: Confused about C# function output
body: <p>When I worked through this example in my head I got an output of <code>4 8 3</code>. When I run the function however I get the output <code>4 8 6</code>, I understand how to get the <code>4</code> and the <code>8</code> but I can't understand how <code>y = 6</code>. Shouldn't <code>y = 3</code>? <code>a1</code> runs which results in <code>y +=1</code> so <code>y = 1</code> then <code>a2</code> runs which results in <code>y+=2</code> so <code>y = 3</code>.</p>
  
  <pre><code>void Main() {
      int y = 0;
      Func&lt;int,bool&gt; even = (n) =&gt; { return n%2 == 0; };
      Func&lt;int,int&gt; dub = (n) =&gt; { y += 2; return n + n; };
      Func&lt;int,int&gt; succ = (n) =&gt; { y += 1; return n + 1; };
  
      Func&lt;bool, int, int, int&gt; if1 = (c, t, f) =&gt; c? t: f;
      y = 0;
      var a1 = if1(even(3), dub(3), succ(3));
      var a2 = if1(even(4), dub(4), succ(4));
  
      Console.WriteLine("{0} {1} {2}", a1, a2, y);
  }
  </code></pre>