forked from swiftlang/swift
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathselector_arguments.swift
28 lines (19 loc) · 943 Bytes
/
selector_arguments.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// RUN: %target-run-simple-swift | FileCheck %s
// REQUIRES: executable_test
func divide(_ a: Int, byDividend b: Int) -> Int { return a / b }
print(divide(12, byDividend: 4)) // CHECK: 3
print(divide(12, byDividend:3)) // CHECK: 4
var f : (_:Int, byDividend:Int) -> Int = divide
print(f(20, byDividend:2)) // CHECK: 10
func divide(_ a: Int, byDividends b: Int, _ c: Int, thenAdd d: Int) -> Int {
return a / b / c + d
}
func divide(_ a: Int, byDividends b: Int, _ c: Int, _ d: Int, thenAdd e: Int) -> Int {
return a / b / c / d + e
}
print(divide(60, byDividends:2, 3, thenAdd:100)) // CHECK: 110
print(divide(60, byDividends:2, 3, 5, thenAdd:100)) // CHECK: 102
var g : (_:Int, byDividends:Int, _:Int, thenAdd:Int) -> Int = divide
var h : (_:Int, byDividends:Int, _:Int, _:Int, thenAdd:Int) -> Int = divide
print(g(60, byDividends:2, 3, thenAdd:300)) // CHECK: 310
print(h(60, byDividends:2, 3, 5, thenAdd:300)) // CHECK: 302