Unexpected trailing closure

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Unexpected trailing closure

Marco S Hyman
I ran into this converting some code to swift 2 on Xcode 7

class SomeClass: NSObject {
    lazy foo = Foo(windowNibName: “Foo” )
    // ...
}

where Foo is a subclass of NSWindowController.  That generated an error about
an unexpected trailing closure.   Changing the line to

    lazy foo: Foo = Foo(windowNibName: “Foo”)

compiles clean.  Swift beta glitch or am I missing something?

--
You received this message because you are subscribed to the Google Groups "Swift Language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/swift-language/C3302D26-85D2-4F38-91BF-A0E33600E088%40snafu.org.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Unexpected trailing closure

Brent Royal-Gordon-2
Is it really "lazy foo"? Because it should be "lazy var foo".

On Fri, Jun 19, 2015 at 12:05 AM Marco S Hyman <[hidden email]> wrote:
I ran into this converting some code to swift 2 on Xcode 7

class SomeClass: NSObject {
    lazy foo = Foo(windowNibName: “Foo” )
    // ...
}

where Foo is a subclass of NSWindowController.  That generated an error about
an unexpected trailing closure.   Changing the line to

    lazy foo: Foo = Foo(windowNibName: “Foo”)

compiles clean.  Swift beta glitch or am I missing something?

--
You received this message because you are subscribed to the Google Groups "Swift Language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/swift-language/C3302D26-85D2-4F38-91BF-A0E33600E088%40snafu.org.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Swift Language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/swift-language/CAEeRk-bGWm1BOGhDfxDHdUcPSWn%2BhknKzWaq-OjBj6seZXE_nw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Unexpected trailing closure

Marco S Hyman
On Jun 19, 2015, at 2:40 AM, Brent Royal-Gordon <[hidden email]> wrote:
>
> Is it really "lazy foo"? Because it should be "lazy var foo”.

email typo.  It is lazy var foo.   Cutting and pasting from the actual
code:


final class AppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate {
    ...
    lazy var preferences: Preferences = Preferences(windowNibName: Preferences.nibName)
    ...
}

That works.  Removing the ": Preferences” generates the error.



--
You received this message because you are subscribed to the Google Groups "Swift Language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/swift-language/9567B0FE-55BF-4666-8EAB-E70B0856DE25%40snafu.org.
For more options, visit https://groups.google.com/d/optout.