Sign in Join
Wiki copytemporary

Variable parameter/es: what changed

Revision 0 to 1. Removed lines have a minus sign; added lines have a plus sign.

Title: Variable parameter/es

OldNewLine
1+Un parámetro variable (o parámetro *pasado por referencia*) es un parámetro de entrada y salida, lo que significa que se utiliza para pasar un valor a la [[Function/es|función]] o al [[Procedure|procedimiento]] y que también sirve para recuperar desde fuera, el valor que dentro de la función o procedimiento ha tomado la variable. Se indica mediante la [[Keyword|palabra reservada]] [[Var/es|var]] delante del parámetro formal.
2+
3+El nombre del parámetro de la definición es un apodo de la variable que se pasa. El dentro del método se hace referencia a la misma variable y los cambios realizados tienen efecto en la variable actual.
4+
5+## XOR swap
6+
7+``` pascal
8+
9+procedure XorSwap( var i,j:integer );
10+ begin
11+ i := i xor j ;
12+ j := i xor j ;
13+ i := i xor j ;
14+ end;
15+```
16+
17+## OrderSmallBig
18+
19+``` pascal
20+
21+procedure OrderSmallBig( var a,b:integer );
22+ begin
23+ if a > b then XorSwap( a, b );
24+ // tras la llamada a tendrá el valor anterior de b y b tendrá el antiguo de a
25+ end;
26+```
27+
28+## Leer también
29+
30+- [Variable parameter](http://lazarus-ccr.sourceforge.net/fpcdoc/ref/refsu48.html)
31+- [[Basic Pascal Tutorial/Chapter 4/Parameters/es|Parámetros]]
32+- [[Xor]]
33+- [[If]]
34+
35+---
36+*From the Free Pascal wiki, page "Variable parameter/es", as it stood on 2023-01-25 after a change by Kai Burghardt, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).*
37+Category: Castellano
38+Category: Español

Back to history