Return multiple values: Difference between revisions

Added UNIX Shell solution
m (→‎{{header|Java}}: Some other style corrections)
(Added UNIX Shell solution)
Line 1,239:
Successful call binding only one new variable:
<lang txr>@(func "a" "b" s)</lang>
 
=={{header|UNIX Shell}}==
Shell scripts don't directly support returning values from a function, it can be simulated through some clunky code.
 
<lang bash>
#!/bin/sh
funct1() {
a=$1
b=`expr $a + 1`
echo $a $b
}
 
values=`funct1 5`
 
set $values
x=$1
y=$2
echo "x=$x"
echo "y=$y"
</lang>
 
Output produced:
 
<pre>
x=5
y=6
</pre>
 
=={{header|XPL0}}==