What does += mean in Swift?

The expression a += 2 is shorthand for a = a + 2 . Effectively, the addition and the assignment are combined into one operator that performs both tasks at the same time . Note. The compound assignment operators don’t return a value. For example, you can’t write let b = a += 2 .

Read more

Why do we use _ in Swift?

The _ is a placeholder for the parameter name . In your example, you call them differently, in the second function, you need to write the parameter name a: 1 . Swift’s function name convention is funcName(param1:param2:) , and it needs the _ as a placeholder to create the name of the function.

Read more

What is the symbol in Swift?

Put simply, @UIApplicationMain is an indicator for Swift applications that indicates which object is your application’s main application delegate file. In Objective-C application templates, you would have a trivial main. m C file which sets the application delegate.

Read more

What does == mean in Swift?

The == or equality operator checks whether the two operands are equal . What equal means for an object depends on the implementation of the class or structure. For the NSArray class, the contents of the arrays are compared. In the above example, arr1 is equal to arr2 because the values stored in the arrays are equal.

Read more