In swift, expressions have many forms
1. Do not specify a data type
var a1=10
var a2=20
var a=a1>a2? " A1 ":" A2 "
In the above expression, the variable or constant is assigned directly, and no data type is specified because Swift can automatically determine the data type
2. Specify the data type
var a1:int=10
var a2:int=20
var a=a1>a2? " A1 ":" A2 "
In the above expression, specify the int data type for variables and constants, which makes the program readable;
3. Using layering
var A1:int=10;var a2:int=20
var a=a1>a2? " A1 ":" A2 "
In the swift language, a statement can be terminated without a semicolon or a semicolon, but there is a case where a semicolon is required, that is, when multiple statements are written on the same line, a semicolon is used to differentiate the statement, for example:
This article is from the "Ordinary Road" blog, please be sure to keep this source http://linjohn.blog.51cto.com/1026193/1619004
Expressions for Swift