I stumbled on the exact same question and I'm having the same issues in searching for answers. I'm still learning Swift, but the answers here - https://stackoverflow.com/questions/36996012/how-can-i-allow-my-function-to-accepts-two-different-objects-in-swift match my previous programming experience. You can use class inheritance, either inheriting from another class that implements the method or from a protocol (which seems similar to an interface in C#). But the question here is what is the class or protocol that implements the moveForward() function?
Post
Replies
Boosts
Views
Activity
It seems Expert and Character derive from the class Actor. So one way to do it is:
func mover(persona: Actor, times: Int){
for i in 1 ... times {
persona.moveForward()
}
}