detail
You might have wondered: If Ferret allows you to return named values but also has a normal single-value type return statement, what happens if you use both?
detail
allows you to request "more detail" from a
function call whose named return values would have otherwise been overridden
by a traditional return statement. This means that, regardless of any
explicit ->
statements that may exist,
the detail
call will always yield the
return object.
If at least one explicit ->
did exist, the most recent one determines the
value of the result
property of said return object. Consider this example.
func A { x -> "a named return value" y -> "another named value" -> "the ultimate value" } A()
A()
will always be "the ultimate value"
, and the named return values
are inaccessible. detail
fixes this like so.
$ret = detail A() $ret.x # "a return value" $ret.y # "another value" $ret.result # "the ultimate value"
This may seem unnecessary right now, but it'll make more sense later when we get to event propagation, modules, and habits for writing dynamically extensible code.
Let's take a break from functions for awhile. We'll come back to look at some more advanced features later.