The definition of a beginner Swift note variable (i.)

Source: Internet
Author: User

definition of Swift variable
1 Import Foundation2 3 /*4 definition of a variable5 The type of the variable can be used without writing6 var a=107 definition of constants let decoration8 */9 Ten varA=Ten One print (a) ALet b= One - print (b) - the /* - Type Callout - Specify the type of variable: [space] Capitalize first letter - */ + varX:int -x=9 + print (x) ALet y:int=Ten at print (y) - /* - Naming Conventions - specification for name without compound marker - */ - var_ttx=Ten in print (_TTX) - /* to basic type All data types are capitalized in the first letter + integer type, decimal type - Int Int8 Int16 Int32 Int64 the UInt uint8/16/32/64 Unsigned numeric type value cannot be negative * floating-point data $ double/floatPanax Notoginseng */ - varInterger:int32=Ten the print (Interger) + vart:float=2.123 A print (t) the vartt:double=2.12 + print (TT) -t=Float (TT) $ print (t) $ /* - type inference and type safety - assign an initial value when declaring a type the */ - varStr=""WuyiStr="string" the print (str) - //Type Conversions WuLet trueof:bool=true - iftrueof{ AboutPrint"true") $}Else{ -Print"false") - } - //Meta-group A varStudent= ("a",true,"C",Ten) +Print (student.0) the varstudents= (Name:"Liushiqun", Age:Ten, Address:"Beijing") - print (students.name) $ //Optional value Optional type the varoptvalue:int?= - the //! Represents a forced resolution of an optional value the //var svalue:int=optvalue! the - //print (svalue) in if(Optvalue! =Nil) { the print (Optvalue) the } About varStvalue=0 the the //Evaluation of the assignment of an optional value the if varS_tvalue =Optvalue { +Stvalue=S_tvalue - print (Stvalue) the }Bayi //implicitly resolves an optional type the varoptvalue1:int!=9 the if(Optvalue1! =Nil) { - print (optvalue1) - } the if varIvalue=optvalue1 { the print (ivalue) the } the varI_values:int=optvalue1 - print (i_values) theprintln"Hello")

The definition of a beginner Swift note variable (i.)

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.