Unexpected trailing closure

194 views
Skip to first unread message

Marco S Hyman

unread,
Jun 19, 2015, 3:05:57 AM6/19/15
to swift-l...@googlegroups.com
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?

Brent Royal-Gordon

unread,
Jun 19, 2015, 5:40:13 AM6/19/15
to Marco S Hyman, swift-l...@googlegroups.com
Is it really "lazy foo"? Because it should be "lazy var foo".

--
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 swift-languag...@googlegroups.com.
To post to this group, send email to swift-l...@googlegroups.com.
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.

Marco S Hyman

unread,
Jun 19, 2015, 12:33:37 PM6/19/15
to Brent Royal-Gordon, swift-l...@googlegroups.com
On Jun 19, 2015, at 2:40 AM, Brent Royal-Gordon <br...@brentdax.com> 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.



Reply all
Reply to author
Forward
0 new messages