Swift Basic Syntax

Source: Internet
Author: User

SWIFT1 Basic Syntax

Constants and variables

Type callout

Names of constants and variables

Output Constants and variables

Comments

Semicolon

Data type conversions

Boolean value

Meta-group

Optional type

Optional bindings

implicitly resolves an optional type

Using Assertions for debugging

Interval operator

Semi-open interval operator

String initialization

Concatenation of strings

Character Traversal in strings

Character data type

string interpolation

Calculating the number of characters

String index

Indeces use

String deletion

string comparison

Prefix suffix

Create an empty array

Create an array with a default value

Two arrays added

Construct an array in literal quantities

Accessing and modifying arrays

Iterating through an array

Create an empty collection

Create a collection with literal amounts

Adding a Delete collection element

Operation of the collection

Union Merge Collection

Intersect intersection

Subtract an array that is not in a collection

Exclusiveor not in two collections


The relationship between collections

Use the equality operator (= =) to determine whether two sets contain all the same values.

Use The IsSubsetOf (_:) method is used to determine whether a value in a collection is also contained in another collection.

use issupersetof (_:) method to determine that a collection contains all of the values in another collection.

    • Use Isstrictsubsetof (_:) or isstrictsupersetof (_:) method to determine whether a collection is a subset of another collection, or a parent collection, and the two sets are not merged equally.
    • Use The Isdisjointwith (_:) method determines whether two sets do not contain the same value (whether there is no intersection).

    • Create an empty Dictionary
    • Create a dictionary with literal amounts
    • Accessing and modifying dictionaries
    • Dictionary traversal
    • Ordered output of dictionaries


    • For ... In structure

While structure

A while loop with labels

Repeat...while structure

Tuples in Switch...case _ use

Tuple value bindings in Switch...case

The WHERE condition statement in Switch...case

The fall through in Switch...case


Definition and invocation of a function

function parameters and return values

Tuples as return values

Optional tuple as return value

Develop function external parameters

Ignore function external parameters

function default parameter value

Function-Distinguishing parameters

function constant parameters and variable arguments

function input and OUTPUT parameters

Swift Basic Syntax

Related Article

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.