Apollo Apollo - 1 year ago 97
Swift Question

Reference structure within definition - Swift

struct Person {
var age: Int
var name: String
var siblings: Int

func sameAge(Person: p1, Person: p2) -> Boolean {
return (p1.age == p2.age)

How can I reference a structure that I'm defining within its own definition, like in the example above?

The error I see is

Definition conflicts with previous value

Answer Source

Parameter types should go after the colon:

func sameAge(p1: Person, _ p2 : Person) -> Boolean {
    return (p1.age == p2.age)
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download