I'm a starter on Swift. I'm a little confused about the result of the codes below.
What will happen if I pass printer() to call() and call the call function? To be more specific, the variable strings is defined in a class and the function printer() will print it out. But the point is, only the printer() function is passed as an argument to a structure defined in another file, the strings variable doesn't get passed. So how does swift cope with this situation and what is the mechanism behind it (if it can run successfully)?
Code Block class handler { static var strings: Array<String> = ["a", "b"] static func printer() -> Void{ print(strings) } }
Code Block /* defined in another file */ struct Caller { func call(function:() -> Void){ function() } }
What will happen if I pass printer() to call() and call the call function? To be more specific, the variable strings is defined in a class and the function printer() will print it out. But the point is, only the printer() function is passed as an argument to a structure defined in another file, the strings variable doesn't get passed. So how does swift cope with this situation and what is the mechanism behind it (if it can run successfully)?