returning different types via function

Ali Çehreli acehreli at yahoo.com
Tue Nov 19 11:30:47 PST 2013


On 11/19/2013 11:15 AM, seany wrote:

 > Consider this:
 >
 > I have a function FUNC, it takes a string array, and does something with
 > it, and retruns the same. Implemented based on a previous thread, here
 > is what i have
 >
 > string[] FUNC (ref string[] ZZ)
 > {
 > /*
 > do something
 > */
 > }
 >
 > and the calling is, ZZ = FUNC(ZZ)

In addition to what the others said, I see two more options:

a) Instead of returning the same slice return a flag. (The slice is 
available through the out parameter anyway.)

b) Return a struct (or Tuple) with two members.

Ali



More information about the Digitalmars-d-learn mailing list