Swift: Assignment operator

Assignment operators in Swift perform two basic functions: Initialise a value or update a value. Consider the example  var a = b + c . Here the assignment operator ‘=’ assigns the value of b+ c to a. Unlike other languages, in Swift the assignment operator will not return a value.  if x = y  is not valid in Swift. When tuples are assigned to variables, they can be decomposed into individual constants and variables as needed.

Swift code:

Output:

Leave a Reply