[swift-users] [Possible bug] Initialising multiple instance variables from a closure

Karl razielim at gmail.com
Wed Jun 29 19:57:50 CDT 2016


Currently you can initialise a class instance variable from a closure:

let textView : UITextView = {
		let t = UITextView()
		t.translatesAutoresizingMaskIntoConstraints = false
		t.autocapitalizationType = .none
		t.autocorrectionType = .no
		t.spellCheckingType = .no
		return t
	}()

However, it doesn’t seem to be possible to return and initialise multiple variables from a closure:

	let (toolbar : UIToolbar, aButton : UIBarButtonItem) = {        // ERROR: Type of expression is ambiguous without more context
		let toolbar = UIToolbar()
		let aButton = UIBarButtonItem()
		return (toolbar, aButton)
	}()

Is this something which, in theory should be supported?

Thanks

Karl


More information about the swift-users mailing list