multiple returns from a function (sorry, method!)

  • Thread starter Graham Nicholls
  • Start date
G

Graham Nicholls

Take a look at this method call:

(line,format_line)=replace_tabs(line,fmt_line,@current_ruler)

in the method replace_tabs, format line ha the right value,
but in the caller, its not receiving it.


This is how I'm returning the values:
return([line,format_line])

which I understand to mean that I'm returning an array, so I suppose I need
to know how to "unpack" the array into the two receiving values

Thanks
Graham Nicholls
 
G

Graham Nicholls

Graham said:
Take a look at this method call:

(line,format_line)=replace_tabs(line,fmt_line,@current_ruler)

in the method replace_tabs, format line ha the right value,
but in the caller, its not receiving it.


This is how I'm returning the values:
return([line,format_line])

which I understand to mean that I'm returning an array, so I suppose I
need to know how to "unpack" the array into the two receiving values

Thanks
Graham Nicholls
Doh!, it works - I just put in some debugging, andthe caller is getting the
values. Problem must be elsewhere.

Thanks, anyway!
Graham
 
A

Alexander Kellett

(line,format_line)=replace_tabs(line,fmt_line,@current_ruler)

line, format_line = replace_tabs(line, fmt_line, @current_ruler)
This is how I'm returning the values:
return([line,format_line])

return line, format_line

Alex
 
R

Robert Klemme

Alexander Kellett said:
(line,format_line)=replace_tabs(line,fmt_line,@current_ruler)

line, format_line = replace_tabs(line, fmt_line, @current_ruler)
This is how I'm returning the values:
return([line,format_line])

return line, format_line

Both work as expected, but I find the latter much cleaner.

robert
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,011
Latest member
AjaUqq1950

Latest Threads

Top