Generic swap: Difference between revisions
Jakt
(Jakt) |
|||
Line 1,852:
V2
cat</syntaxhighlight>
=={{header|Jakt}}==
<syntaxhighlight lang="jakt">
fn swap<T>(anon a: &mut T, anon b: &mut T) {
let temporary = *a
*a = *b
*b = temporary
}
fn main() {
mut a = "Hello"
mut b = "World"
println("{} {}", a, b)
swap(&mut a, &mut b)
println("{} {}", a, b)
mut c = 1
mut d = 2
println("{} {}", c, d)
swap(&mut c, &mut d)
println("{} {}", c, d)
}
</syntaxhighlight>
=={{header|Java}}==
|