Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,30 @@
mixed first = 5;
mixed second = "foo";
array pair = ({ 5, "foo" });
void swapvars(string a, string b)
{
[this[a], this[b]] = ({ this[b], this[a] });
}
void swaparray(array swapit)
{
[swapit[1], swapit[0]] = ({ swapit[0], swapit[1] });
}
void main()
{
write("swap variables:\n");
write("%O, %O\n", first, second);
// we could just use [first, second] = ({ second, first });
swapvars("first", "second");
write("%O, %O\n", first, second);
write("swap array:\n");
write("%{ %O %}\n", pair);
// we could just use [pair[1], pair[0]] = ({ pair[0], pair[1] });
// directly, but since arrays are called by reference,
// it also works through a function
swaparray(pair);
write("%{%O %}\n", pair);
}