메모리 안전
메모리 안전의 개념

Untitled
var stepConflict = 1 func increment(_ number: inout Int) { number += stepConflict } increment(&stepConflict) // 동시 접근으로 인한 문제func balance(_ x: inout Int, _ y: inout Int) { // 평균값 설정하는 함수 let sum = x + y x = sum / 2 y = sum - x } var playerOneScore = 42 var playerTwoScore = 30 // 입출력 파라미터로 동일한 변수를 전달하고 있음 //balance(&playerOneScore, &playerOneScore) // 에러 발생 ⭐️, 하나의 메모리에 동시에 접근할 수도 있음. balance(&playerOneScore, &playerTwoScore) // 에러 발생하지 않음
값타입 인스턴스
Last updated