<div dir="ltr"><div>I asked the same question on twitter, and it resulted in some interesting finds:<br></div><div><a href="https://twitter.com/bitCycle/status/778697998893142016">https://twitter.com/bitCycle/status/778697998893142016</a><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Sep 22, 2016 at 12:41 AM, Zhao Xin <span dir="ltr"><<a href="mailto:owenzx@gmail.com" target="_blank">owenzx@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_default" style="font-family:georgia,serif">I suggest you defining the variables before using them like Marco does. Although from the global variable point of view, both way should be fine. But the glitch does exist, especially in playground.</div><div class="gmail_default" style="font-family:georgia,serif"><br></div><div class="gmail_default" style="font-family:georgia,serif">Zhaoxin</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Sep 22, 2016 at 5:59 AM, Marco S Hyman via swift-users <span dir="ltr"><<a href="mailto:swift-users@swift.org" target="_blank">swift-users@swift.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5"><div><div><br>
> On Sep 21, 2016, at 2:22 PM, Jens Persson via swift-users <<a href="mailto:swift-users@swift.org" target="_blank">swift-users@swift.org</a>> wrote:<br>
><br>
> // This little Swift program compiles (and runs) fine:<br>
><br>
> func foo() -> Int { return a }<br>
> let a = 1<br>
> let b = 2<br>
> print(foo())<br>
><br>
> But if `foo()` returns `b` instead of `a`, I get this compile time error:<br>
</div></div></div></div>> "Use of unresolved identifier `b`”<br>
<br>
Interesting. Seems to have something to do with ordering as if you code it this way:<span class=""><br>
<span><br>
let a = 1<br>
let b = 2<br>
</span></span>func foo() -> Int { return b }<br>
print(foo())<br>
<br>
it works fine (Xcode 8 playground).<br>
______________________________<wbr>_________________<br>
swift-users mailing list<br>
<a href="mailto:swift-users@swift.org" target="_blank">swift-users@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-users" rel="noreferrer" target="_blank">https://lists.swift.org/mailma<wbr>n/listinfo/swift-users</a><br>
</blockquote></div><br></div>
</blockquote></div><br></div>