Operators

Overview

Conditional & Logical Operators

OperatorDescription

:

Declares to property

=

Assign, to be

==

Equals to

===

Identical to

!===

Note identical to

!=

Not equal to

!

Not

>

Comparison - Greater then

<

Comparison - Less then

&&

And (Ampersand-Ampersand)

||

Or

? :

Ternary Conditional Operator => "expression ? true-value : false value"

?

Optional, there might not be anything

??

Nil-Coalescing Operator (Checks whether an optional contains a value or not)

$

Two-Way-Binding

\()

Parentezin içine hangi field 'ı istiyorsan onu yazıyorsun

...

up to and including

..<

up to but excluding

%

Remainder

->

Return

\

Quote "His best selling book is \"The Power of Habits\" for years"

Compound Assignment Operators

OperatorDescription

+=

Adds to itself

-=

Subtracts from itself

*=

Multiplies itself

/=

Divides itself

Unary Operators

OperatorDescription

+

Turns negative number into positive

-

Turns positive number inti negative

Example
var numberpositive: Int = 6 // print: 6
var numbernegative = -numberpositive // print: -6

Other Operators

OperatorDescription

" " (quote)

String

""" """ (triple quote)

Multi-Line String

\n

Linebreak, New Textline

Optionals

when you define a variable as an Int you write "= Int"

But if you don't want to define it in advance you will add "?" sign to end of it like "= Int?"

Latter gives you a flexibility but the former

Sample Codes

let pers1 = "Sedat"
let pers2 = "Veysel"
pers1 == pers2 //: false
pers2 > pers1 //: true, çünkü Veysel kelimesi Sedat kelimesinden sonra gelir
let movie = """
A day in
the life of oan
Apple engineer
"""

Sources

Videos

Articles / Documents

Last updated