1 2 3 4 5 6 7 8 9 10 11 12
|
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>Retorno</title><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot"><link rel="home" href="index.html" title="Manual de Genius"><link rel="up" href="ch06.html" title="Chapter 6. Programar con GEL"><link rel="prev" href="ch06s06.html" title="Variables de parámetros"><link rel="next" href="ch06s08.html" title="Referencias"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Retorno</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="ch06s06.html">Prev</a> </td><th width="60%" align="center">Chapter 6. Programar con GEL</th><td width="20%" align="right"> <a accesskey="n" href="ch06s08.html">Next</a></td></tr></table><hr></div><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="genius-gel-returning"></a>Retorno</h2></div></div></div><p>Normalmente, una función se compone de una o varias expresiones separadas con punto y coma, y se devuelve el valor de la última expresión. Esto resulta útil en funciones sencillas, pero algunas veces no querrá que una función devuelva el resultado del último cálculo. Podría, por ejemplo, preferir que ésta devolviera algún valor obtenido a la mitad de la función. En este caso, puede utilizar la palabra <code class="literal">return</code>. La función <code class="literal">return</code> toma un único valor, que es el valor que se devolverá.</p><p lang="en">
Example:
</p><pre lang="en" class="programlisting">function f(x) = (
y=1;
while true do (
if x>50 then return y;
y=y+1;
x=x+1
)
)
</pre><p lang="en">
</p></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="ch06s06.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="ch06.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="ch06s08.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Variables de parámetros </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> Referencias</td></tr></table></div></body></html>
|