Swift connection strings and characters

Source: Internet
Author: User

1The values of strings and characters can be obtained by the addition operator (+) to add together and create a new string value:2Let string1 ="Hello"3Let string2 ="there"4Let Character1:character ="!"5Let Character2:character ="?"6Let Stringpluscharacter = string1 + character1//equals "hello!."7Let stringplusstring = string1 + string2//equals "Hello there"8Let characterplusstring = Character1 + string1//equals "!hello."9Let Characterpluscharacter = Character1 + character2//equals "!?"TenYou can also use the addition assignment operator (+ =) adds a string or character to a string variable that already exists: Onevar instruction =" look over" AInstruction + =string2 - //instruction now equals "look over there." -var welcome ="Good Morning" theWelcome + =Character1 - //welcome now equals "good morning!." -Note: You cannot add a string or character to a character variable that already exists because the character variable can contain only one character.

Swift connection strings and characters

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.