???Eiffel idiom for multiple return values???
Quote:
Kaelin Colclasure writes:
> Is there an idiom in Eiffel for functions which return multiple
> values?
> > I have a class which conceptually has three integer attributes...
.
.
Quote:
> Voice: (314)567-8463 717 Office Parkway// Fax:
> (314)432-5391 St. Louis, MO 63141
My approach is to return a reference to an instance of a class for which
these values are some of its features. eg:
class XYPAIR -- A class that could be a point or a vector.
.
feature x, y: REAL -- The instance's current values.
.
make (initial_x, initial_y)
.
All sorts of other features that do appropriate things
with 'x' & 'y'...
.
Then a feature in some other class that wants to return an XYPAIR
could look like this:
class SHIP
.
feature
position: XYPAIR -- Ship's position at sea.
.
make (lat,long: REAL...
.
!!position.make (lat, long)
.
.
where: XYPAIR is -- What is your position?
is
Result := clone (position)
end
.