0

I just discovered that there is no possible straightforeward way to compare two functions in swift, meaning this code does not compile:

func foo1() {}
func foo2() {}
assert(foo1 === foo1)
assert(foo1 !== foo2)

This strikes me, because I know functions use reference semantics and therefore it shouldn't be a problem to compare two references, as it is possible in C with function pointers.

Can anyone provide me an explanation of this restriction and does anyone know a workaround for this?

tierriminator
  • 587
  • 5
  • 19

0 Answers0