[swift-users] Closure "shadowing" functions.

Jens Alfke jens at mooseyard.com
Fri Jan 8 11:08:27 CST 2016


> On Jan 8, 2016, at 4:24 AM, Wallacy via swift-users <swift-users at swift.org> wrote:
> 
> class iClass{
>     let myProperty:(String)->() = { value in
>         print("1: \(value)");
>     }
>     func myProperty(value: String)->() {
>         print("2: \(value)");
>     }
> }

I’m surprised Swift even allows you to declare a property and a method with the same name.
Why don’t you just rename one of them?

—Jens



More information about the swift-users mailing list