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
2
Q
What is a Ternary conditional operator? How does it work? What is it short hand for?
A
3
Q
What is a Nil-Coalescing operator?
A
4
Q
What are the different types of range operators and what are thier forms?
A
- Closed Range Operator
- a..b - goes from a to b, including both a and b, a cannot be greater than b
- Half-Open Ranger Operator
- a..
- 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