0

I got a mysterious error-message in swift, xcode:

The following code has an error at the line with somethingElse(p) that says "Use of unresolved identifier 'somethingElse'".

enum symbol: Int {
    case x = 1
    case o = 2
}

class player {
    var p: symbole

    init(p: symbol) {
        self.p = symbol
    }

    func something() {
        somethingElse(p)
    }
}

but when I called the method and worked with it like

func somethingElse(p: symbol) {
    bla = p
}


var test = player(p: .x)
test.something()
bla

the error-message still appears, but everything works fine.

Jere
  • 1,196
  • 1
  • 9
  • 31

1 Answers1

0

This code compiles fine:

enum symbol: Int {
    case x = 1
    case o = 2
}

class player {
    var p: symbol

    init(p: symbol) {
        self.p = p
    }

    func something() {
        somethingElse(p)
    }
}

func somethingElse(p: symbol) {
    //bla = p
}

var test = player(p: .x)
test.something()
//bla
Daniel T.
  • 32,821
  • 6
  • 50
  • 72