Beginner Swift note operator (ii)

Source: Internet
Author: User

Operators in Swift

Import Foundation//Character Typevar Char: Character ="a"Char="b"println (Char)varStr:stringstr="abcceadfasdfl;jk\0dfaaaa 0001496"println (str)//View length countelements the number of elements returnedprintln (countelements (str))varstr1="Hrllo"println (str1+" World")//string formatting \ (string, variable, expression)varindex="ABC"varMessage="http://www.baidu.com/tag=\ (index). PNG"println (message)//The comparison of strings is encoded, not contentLet m_s1="HeLlo"Let m_s2="Hello World"ifM_S1 = =m_s2{println ("equals")}ifM_S1 >=m_s2{println ("greater than or equal")}ifM_S1 <=m_s2{println ("less than or equal")}ifM_s1 <m_s2{println ("less than")}ifM_s1 >m_s2{println ("Greater than")}ifM_s1.hassuffix ("Lo") {println ("suffix")}ifM_s1.hasprefix ("He") {println ("prefix")}println (m_s1.lowercasestring+"Turn lowercase") println (m_s1.uppercasestring+"Turn Capital")//Type Conversionsvarn_s1="255"println (N_s1.toint ())//What you get is an optional value.//closed interval operator (A...B) for_inch(1...5){   //println ("Hello")} forIinch(1...5) {println ("Hello"+String (i))}//semi-closed interval operator (a). <B) forIinch(1.. <5) {println (i)}

Beginner Swift note operator (ii)

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.