My thinking is that is functionB does...
return %myhash;
...then it's therefore returning a hash. In which case to pass a reference to that to functionA it would have to be...
$obj->functionA({ $obj->functionB() });
But if functionB did...
return @myarray;
Then I'd have to do...
$obj->functionA([ $obj->functionB() ]);
And it functionB did return...
return $scalar or return \$ref
Then it would be...
$obj->functionA($obj->functionB());
My problem is that I don't know which one of those four possibilities functionB is going to do, and therefore don't know whether to wrap it in braces (for a hash ref) or square brackets (for an array ref) or nothing (for a scalar, or if it's already a reference).
You have got me thinking however that I should always be doing the square bracket array reference however, because functionA can always find a way to deal with that.
In reply to Re^4: Auto-detecting returned or passed variable type
by richard5mith
in thread Auto-detecting returned or passed variable type
by richard5mith
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |