On Friday, March 02, 2012 09:31:14 kennytm wrote: > Jonathan M Davis <[email protected]> wrote: > > That's assuming that you're passing all of the pieces of the tuple to the > > function. Often, that's not the case at all. Take the findSplit trio, for > > instance. What are the odds that you're going to want to pass all of the > > elements in the tuples that any of the return to another function? About > > zero, I'd say. It's _much_ more likely that you're going to want to take > > the results and then pass _one_ of them to another function. So, as it > > stands, chaining with those functions just doesn't work unless you only > > care about one of the results in the tuple. > > > > - Jonathan M Davis > > How does 'out' make chaining any easier? Suppose we have a `R3 > findSplit2(R1, R2, out R4, out R5)`, how to chain if we want to pass the R4 > to another function? > > R5 ignored; > R4 theRange; > findSplit2(haystack, needle, theRange, ignored); > return doSomething(theRange); > > vs > > return doSomething(findSplit(haystack, needle)[1]);
True, you can't chain using the out parameters, but you _can_ chain using the return value, whereas if you have a tuple, you can't chain _at all_ unless you actually need all of the returned values (either as a tuple or expanded) or if you only need _one_ of the returned values, in which case you can use the subscript operator. So, you can definitely chain better without a tuple than with. - Jonathan M Davis
