mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
23 lines
691 B
Swift
23 lines
691 B
Swift
// RUN: %target-run-simple-swift | FileCheck %s
|
|
// REQUIRES: executable_test
|
|
|
|
var x: Int! = 0
|
|
x! = 2
|
|
print(x) // CHECK: 2
|
|
x! += 1
|
|
print(x) // CHECK-NEXT: 3
|
|
|
|
var sequences = ["fibonacci": [1, 1, 2, 3, 0]]
|
|
print(sequences) // CHECK-NEXT: ["fibonacci": [1, 1, 2, 3, 0]]
|
|
sequences["fibonacci"]![4] = 5
|
|
print(sequences) // CHECK-NEXT: ["fibonacci": [1, 1, 2, 3, 5]]
|
|
sequences["fibonacci"]!.append(8)
|
|
print(sequences) // CHECK-NEXT: ["fibonacci": [1, 1, 2, 3, 5, 8]]
|
|
|
|
func printAndReturn(x: Int) -> Int { print(x); return x }
|
|
|
|
print("optional binding") // CHECK-NEXT: optional binding
|
|
var y: Int? = nil
|
|
y? += printAndReturn(4)
|
|
print("done with binding test") // CHECK-NEXT: done with binding test
|