You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I wanted to ask if founded by me strange behaviour of compiler/parser is bug or it is 'feature' and 'by design' :
(Swift version 3.0-dev (LLVM b010debd0e, Clang 3e4d01d89b, Swift 7182c58))
(IBM Swift Sandbox)
1. I was not expecting this will compile :
let ft1 : (Int,Int) -> Void = { x in print(x.0, x.1)}
ft1(1, 2)
the type of ft1 is definitely not the same as closure
2. The same. But this generates error in runtime :
let ft2 : (Int,Int) -> Void = { x in print(x)}
ft2(1, 2)
3. Could you describe why this compile, as types of closures are not the same
func z1(block: (Int,Int) -> Void) {
block(1,2)
}
z1 { x, y in print(x,y)}
z1 { x in print(x.0, x.1)}
z1 { (x, y) in print(x, y)}
func z2(block: ((Int,Int)) -> Void) {
block((1,2))
}
z2 { x, y in print(x,y)}
z2 { x in print(x.0, x.1)}
z2 { (x, y) in print(x, y)}
//z2 { ((x, y)) in print(x, y)} // compilation error ???
Thank you for your description and comments.
The text was updated successfully, but these errors were encountered:
Additional Detail from JIRA
md5: e9e08c67a6041aa28a44745bd5d0ebfc
Issue Description:
I wanted to ask if founded by me strange behaviour of compiler/parser is bug or it is 'feature' and 'by design' :
(Swift version 3.0-dev (LLVM b010debd0e, Clang 3e4d01d89b, Swift 7182c58))
(IBM Swift Sandbox)
1. I was not expecting this will compile :
the type of ft1 is definitely not the same as closure
2. The same. But this generates error in runtime :
3. Could you describe why this compile, as types of closures are not the same
Thank you for your description and comments.
The text was updated successfully, but these errors were encountered: