lukzett
1
Let's say I have a function
func something(a: SomeType, b: (AnotherType) -> YetAnotherType) {
// ...
}
Can I get the type of a or b so I can use it in a declaration?
Instead of writing
let test: SomeType?
let block: (AnotherType) -> YetAnotherType = { .. }
I would like to write something along the lines of:
let test: typeOf(#selector(something), at: 0)
let block: typeOf(#selector(something), at: 1) = { .. }
Also something similar for the return type would be nice.
Basically those types can get a bit verbose, I'm looking how to write less and clearer..
Jon_Shier
(Jon Shier)
2
Such dynamic usage isn't possible in Swift (I'll leave it to others to explain exactly why). But if you need less verbose types, use a typealias, especially for closure types.