Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

can swift functions and closures conform to Hashable?

Suppose I want to have a Set of functions or closures. Here's how I would go about it:

typealias HandlerX = () -> ()
static var handlersX = Set<HandlerX>()

This produces the following compiler error:

Type 'HandlerX' (aka '() -> ()') does not conform to protocol 'Hashable'

Is this a dead end?

like image 944
Eric Avatar asked Mar 13 '23 10:03

Eric


1 Answers

Yes, this is a dead end. Hashable isn't really your problem; there's no way to decide whether two closures are Equal (which is a base requirement of Hashable).

like image 187
Rob Napier Avatar answered Mar 25 '23 00:03

Rob Napier