coolly coolly - 5 months ago 6x
Swift Question

How can I allow my function to accepts two different objects in swift?

I have a function which takes one argument. I wanted my function to accept two object types. How can I do it? Here is the example below:

func accept(user: Customer) {

It should accept Customer and Employee object reference.


Please help me in this case.


You can create a super class called People of Cutomer and Employee.

Then set user as type of People:

func accept(user: People) {