- let paddedDouble = 123.000_001
- let oneMillion = 1_000_000
- let http404Error = (404, "Not Found")
- let (_, errorMessage) = http404Error
- let base = 3
- let power = 10
- var answer = 1
- for _ in 1...power {
- answer *= base
- }
- class Counter {
- var count: Int = 0
- func incrementBy(amount: Int, numberOfTimes: Int) {
- count += amount * numberOfTimes
- }
- }
- class Counter {
- var count: Int = 0
- func incrementBy(amount: Int, _ numberOfTimes: Int) {
- count += amount * numberOfTimes
- }
- }
- func join(s1: String, s2: String, joiner: String = " ") -> String {
- return s1 + joiner + s2
- }
- // call the function.
- join("hello", "world", joiner: "-")
- func join(s1: String, s2: String, _ joiner: String = " ") -> String {
- return s1 + joiner + s2
- }
- // call the function.
- join("hello", "world", "-")
- func incrementBy(amount: Int, #numberOfTimes: Int) {
- count += amount * numberOfTimes
- }
- class Counter {
- var count: Int = 0
- func incrementBy(#amount: Int, numberOfTimes: Int) {
- count += amount * numberOfTimes
- }
- }
- var counter = Counter()
- counter.incrementBy(amount: 4, numberOfTimes: 5)
- println(counter.count) // the result is 20
联系客服