[Grammer] 19 - Short-circuit Evaluation, Side Effect, 20 - Assignment Operators

in swift4 •  6 years ago  (edited)
  • Short-circuit Evaluation(단락 평가)
var a = 1
var b = 2
func updateLeft() -> Bool {
   a += 1
   return false
}
func updateRight() -> Bool {
   b += 1
   return true
}

if updateLeft() && updateRight() { }
print(a) // 2
print(b) // 2
  • Side Effect : 오류, 부작용

  • Assignment Operators(할당 연산자)

var a = 1
var b = 2
b = a
a = b
a += 1
Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!