Function that swap two numbers
Hi i need a function that swap 2 numbers I have written code below but it seems to doesn't work. Where am I wrong?
11 Replies
you never used what the method returned
Swap
returns a new tuple, it doesn't modify a
nor b
a
and b
will always be 5 and 10 respectively.I wouldn't even make a function for this
yeah
(b, a) = (a,b)
Windows10CE#8553
REPL Result: Success
Console Output
Compile: 584.628ms | Execution: 36.117ms | React with ❌ to remove this embed.
ohh okay so i can do it that way
will it also works with arrays?
to swap for example 1st elemant of array with 2nd
alternatively u can do this
TheRanger#3357
REPL Result: Success
Console Output
Compile: 548.674ms | Execution: 33.201ms | React with ❌ to remove this embed.
Windows10CE#8553
REPL Result: Success
Console Output
Compile: 612.441ms | Execution: 40.498ms | React with ❌ to remove this embed.
yes, it does
okay so it's that easy
great
thanks you guys! ❤️