Return Values

Because Dylan methods can't have normal “output” parameters in their parameter lists, they're allowed considerably more flexibility when it comes to return values. Methods may return more than one value. As with parameters, these values may be typed or untyped. Interestingly enough, all return values must be named.

A Dylan method—or any other control construct—returns the value of the last expression in its body.

define method foo() => sample :: <string>;
  "Sample string.";		// return string

define method bar() => my-untyped-value;
  if (weekend-day?(today()))
    "Let's party!";	// return string
    make(<excuse>);	// return object
  end if;
end method;

define method moby( )
  =>	sample :: <string>, my-untyped-value;
  values( foo(), bar() ); // return both!

define method baz( ) => ( );
  let (x,y) = moby( );		// assign both