Thursday, January 09, 2020

Swift Opertors - Basic Part 2

Comparision Operator

  • Equal To (==)
  • Not Equal (!=)
  • Less than (<)
  • Greater than (>)
  • Less than or Equal to (<=)
  • Greater than or Equal to (>=)
It reruns either true or false, it is used in if conditional statements.

Tubles comparision:  

                 Left to right comparision, if first element same as second then only it goes for second element comparision.

Ternary Conditional Operator:

  • Question ? answer1: answer 2
  • Example answer = 2 < 5 ? true: false

Nil Coalescing Operator: (??)

  • a ?? b
  • It unwraps an optional a if it contains a value, or returns a default value bif a is nil.
  • a is an optional type here
  • b must  match with the type that is stored inside a.





No comments:

Swift Operators - Basic Part 3 (Range operators in swift)

Range Operators: Closed Range operators  Half-Open Range Operators One-Sided Ranges Closed Range Operators:  a...b It defines...