Website | Source | Language tour
Simple program:
subscript longer_of(_ a: inout String, _ b: inout String): String {
if b.count() > a.count() { yield &b } else { yield &a }
}
fun emphasize(_ z: inout String, strength: Int = 1) {
z.append(repeat_element("!", count: strength)))
}
public fun main() {
var (x, y) = ("Hi", "World")
emphasize(&longer_of[&x, &y])
print("${x} ${y}") // "Hi World!"
}
Last modified 07 October 2024