swift编程语法问题
在swift中,当两个变量和/或函数之间有一个周期时,这意味着什么。我知道这很简单,但我找不到答案,这让我发疯。下面是一个示例程序:swift编程语法问题,swift,Swift,在swift中,当两个变量和/或函数之间有一个周期时,这意味着什么。我知道这很简单,但我找不到答案,这让我发疯。下面是一个示例程序: “let string1 = "hello" let string2 = " there" var welcome = string1 + string2 // welcome now equals "hello there” let exclamationMark: Character = "!" welcome.append(exclamati
“let string1 = "hello"
let string2 = " there"
var welcome = string1 + string2
// welcome now equals "hello there”
let exclamationMark: Character = "!"
welcome.append(exclamationMark)
// welcome now equals "hello there!”
摘自:苹果公司《Swift编程语言》。iBooks
欢迎和附加之间的时间段有什么用?它是做什么的?这就是调用函数“append”的方式,例如“welcome”,将“感叹号”作为参数传递。在目标C中,这将是:
[welcome append: exclamationMark];
通常,句点是访问实例的任何成员(方法或属性)的方式。它被称为“点语法”,这就是用来访问该实例的成员、函数或属性的内容 在同一本书的“快速浏览”一章中:“使用点语法访问实例的属性和方法。”谢谢,这很有意义