The workshop contains quiz questions and exercises to help you solidify your understanding of the material covered. Try to answer all questions before looking at the answers that follow.
- What is the difference between postfix and prefix unary operators?
In the following code, what is the value of the constant c?
let a = 11 let b = 5 let c = a % b
In the following code, what is the value of the variable a?
var a = 5 let b = 6 a *= b
In the following code, what is the value of the constant b?
let a = 5 let b = -a
- What is the difference between two dots with a left angle bracket (..<) and three dots (...) in a range operation?
- The postfix increment does not increase the value of its operand until after it has been evaluated. The prefix decrement increases the value of its operand before it has been evaluated.
- The value of c after the remainder operator is 1.
- The value of a after the compound assignment is 30.
- The value of b after the unary minus operation is -5.
- The two dot with left angle bracket range (..<) is a half-closed range because the upper limit is noninclusive. The three dot range (...) is a closed range because the upper limit is inclusive.