Let's have a simple function:
function sum() { total=$(($1+$2)) }
result=$(sum 10 20)
sum 10 20 result=$?