Basic Operators Flashcards

1
Q

What is a unary minus operator and how does it work?

A

It adds a minus sign to the number, making a positive number negative and a negative number positive

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is a Ternary conditional operator? How does it work? What is it short hand for?

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is a Nil-Coalescing operator?

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What are the different types of range operators and what are thier forms?

A
  1. Closed Range Operator
    • a..b - goes from a to b, including both a and b, a cannot be greater than b
  2. Half-Open Ranger Operator
    • a..
  3. One-Sided Ranges
    • [2…] - starts at 2 and goes to the end of the list
    • […2] - starts at 0 and goes to (and includes 2)
    • [..<2] - starts at 0 and goes to 2 (not including 2)
    • can also be used as let range = …5
How well did you know this?
1
Not at all
2
3
4
5
Perfectly