Rapid Cycling Failure Complex

I know a lot of people who talk about the concept of manifest destiny as if the only thing separating me from more success is my shitty attitude. Maybe that’s true, but also, I don’t believe in…

Smartphone

独家优惠奖金 100% 高达 1 BTC + 180 免费旋转




Swift Operators

An operator is a special symbol or phrase that you use to check, change or combine values. For example, the addition operator adds two numbers in the following one.

&&’ (logical AND)and ‘||’(logical OR) are used to check the conditions by combining other expressions. Example:

a..<b , a…b as a shortcut to express range values.

Terminology: operators are unary, binary and ternary.

Unary Prefix operators appear immediately before their target like !(b) or !(isAllowed). Unary Postfix operators appear immediately after their target like b! or (isAllowed!).

Operators: +, -,*,/, %(Modulo operator, but in swift called as reminder operator which gives reminder in return).

Unary Minus and Unary Plus Operators ->

Unary Plus operator simply returns the same value without any change

Ex: var myAnotherVal = +myNewValue //Equals -54

Compound Assignment Operators: Swift provides compound assignment operators that combine assignment with another operation like

Swift supports all C-language comparison operators. listed below:

→ Tuples also can be compared, if they have the same type and the same number of values. Tuples are compared from left to right, one value at a time until the comparison finds two tuple values that are not equal.

Example :

** Nil-Coalescing Operator:

The nil coalescing operator (a ?? b)unwraps an optional a if it contains a value, or returns the default value b if a value is nil. The expression of ‘a’ must be optional type, and the type of b must match the a’s type.

Swift includes several range operators, which are shortcuts for expressing a range of values.

→ Closed Range Operator: The closed range operator (a…b) defines a range that runs from ‘a’ to ‘b’ and includes the values ‘a’ and ‘b’. The value of ‘a’ must not be greater than ‘b’.

→ Half-Open Range Operator: The half-open range operator (a..<b) defines a range that runs from ‘a’ to ‘b’, but doesn’t include ‘b’. it is called to be half-open because it contains its first value, but not its final value. The value of ‘a’ must not be greater than of ‘b’ value. incase if the ‘a’ and ‘b’ are equal, then the range will be empty.

→ One Sided Ranges : The closed range operator has an alternative form for ranges that continue as far as possible in one direction. For example, if we want to continue from certain index of an Array to the end of the array, we can omit the closed range value. This is called One sided range because, the range is defined with only one side.

→ Logical NOT (!a) : It inverts the boolean value. It is a prefix operator so appears before the operand.

→ Logical AND (a && b) : Both a and b values must be true, for the overall expression to be true. If the first value(a) is false, it doesn’t check the next one as it does not change the output.

→ Logical OR (a || b) : One of the values need to be true for the over all expression to be true. If the first value (a) is true, it also does not need to check the other value as the output does not get affected by the other value.

Add a comment

Related posts:

Ruby on rails for beginners

It has been a while that I have restarted coding Ruby on Rails through boot camp V3 in Jyasaa. It has been an energizing and recalling session for me personally.I am feeling lucky to have been able…

How to workout smarter

This interview with Firas Zahabi popped into my feed casually, didn’t know him but I’m glad I watched it. Damn, he has a lot of wisdom. The main message he explains is that it’s consistency over…

You Can Think And Grow Rich

Whether you are struggling financially or simply looking for a way to make more progress, Napoleon Hill’s book “Think And Grow Rich” has the potential to change your life. While this book focuses on…