[Swift] Study Notes (2)-Basic Operators

Source: Internet
Author: User

Operators are the most commonly used in programming. They include one, two, and three operators. SWIFT is just as basic as other programming languages. The following is a summary of its unique operators, such as interval operators.


1. unary Operators

= Value assignment operator, which is the most used without any return values

+ Addition (Number Addition, can also be used for character concatenation var Ss = "A" + "B ")

-Subtraction

* Multiplication

/Division

% Perform remainder (the negative number is ignored, and the floating point number can also perform remainder)

> Greater

<Less


2. Binary Operators

++ Auto-increment (that is, the abbreviation of I = I + I, which can be frontend ++ I, or suffix I ++. The same is true. frontend time: auto-increment and then return, post: return and auto-increment)

-- Auto-subtraction (equal to I = I-I)

+ = I + = A is short for I = I +

-= Same as above

= Equal

! = Not equal

> = Greater than or equal

<= Less than or equal


3. Ternary Operators

=== Heng et determines whether two objects reference the same object instance

! = Non-Constant

? : Question? True Answer: false answer, for example, VAR a = 0; print ("\ (a> 0? ) ") Output 2

A... B full closed intervals include A and B

A. B semi-closed intervals include a, excluding B.


4. logical operators! & | Non-or (the second is not calculated if the sum or the first condition is met. This is short circuit calculation)



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.