gunw avatar

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

gunw

Published: 25 Jan 2019 › Updated: 25 Jan 2019[Grammer] 19 - Short-circuit Evaluation, Side Effect, 20 - Assignment Operators

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

  • 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

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

Written by

User

Read more #swift4 posts


Best Posts From gunw

We have not curated any of gunw's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.

More Posts From gunw