I'm looking for a solution to avoid this:
func gen<T>(value: T) {
...
}
gen(value: { ... })
or
gen(value: { (a: Int) in ... }
...
We can constrain T to conform to some Protocoles or to be of some types or Any or AnyObject...
We can also check that T is of some Types or AnyObject at the func 1st stage.
But I didn't find any way to say: !Function or !Closure
Any ideas?
lukasa
(Cory Benfield)
2
I think we need some more detail: why are you trying to prevent this?
It's only for academic reasons, to know if it's possible.
lukasa
(Cory Benfield)
4
In Swift as it exists today, it is not possible.