:thread return -x Error Encountered a crash

Im new to Xcode getting this error in this playground, can someone help me here... This was In a playground btw Thanks,

struct Digit {
    var number : Int
    init(_ n: Int){
        self.number = n
    }
    mutating func changeNumberTo(_ n:Int) {
        self.number = n
    }
    func otherFunction(_ f: ()->()) {
    }
    mutating func callAnotherFunction() {
        otherFunction {
            self.changeNumberTo(345) // *
             }
    }
}










var d = Digit(123) // Digit is a struct
print(d.number) //123
var d2 = d //Assignment!
d2.number = 42
print(d.number)





enum Node {
    case none(Int)
    indirect case left(Int, Node)
    indirect case right(Int, Node)
    indirect case both(Int, Node, Node)
}







This was In a playground btw

I’m not able to reproduce the problem. Using Xcode 14.3 on macOS 13.5, I created a new playground from the macOS > Blank template. I then replaced the default code with the code you posted and clicked the Execute Playground button. The code seemed to run just fine, printing:

123
123

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Also tested in Xcode 14.2 playground for iOS. No error.

If changing struct to class (no more mutating), I get the expected results

123
42

So everything works OK.

Which Xcode version do you use ?

BTW: Node not used.

:thread return -x Error Encountered a crash
 
 
Q