Subscripts
subscript min(_ x: Int, _ y: Int): Int {
if x > y { y } else { x }
}
public fun main() {
let one = 1
let two = 2
print(min[one, two]) // 1
}subscript min(_ x: Int, _ y: Int): Int {
print("enter")
yield if x > y { y } else { x }
print("leave")
}
public fun main() {
let one = 1
let two = 2
let z = min[one, two] // enter
print(z) // 1
// leave
}Member subscripts
Subscript bundles
inout subscripts
set subscripts
sink subscripts
Computed properties
Last updated