The Basics
print("Hello, world!")
Constants and Variables
Constatnts and variables must be declared before they are used
let myConstant = 42
var myVariable = 42
Constants need to be assigned a value instantly at creation. You can declare multiple constants or variables on a single line
var x = 0.0, y = 0.0, z = 0.0
Naming
Names can contain Unicode characters.
If you have to use a reserved keyword as a name, wrap it with backticks
let `if` = 4
print(`if`)
Name a variable _
if you want to ignore it.
Comments
Comments in Swift is the same as C, except that multiline comments can be nested
/*
...
/*
* multilines comment
*/
...
*/
Semicolons
Semicolons are required to separate multiple statements on a single line
let cat = "
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。