Intercambio de valores entre 2 variables


En el trabajo nos hemos estado peleando un poco en cómo intercambiar el valor de dos variables sin el uso explícito de una tercera variable auxiliar (pregunta típica de esas que no sirver para nada xD).

En fin ahí va mi propuesta:


a = "hola";
b = "adios";

b = (a + "||" + (a=b)).split("||")[0];

trace (a + " : " + b);

Cómo lo haríais vosotros?

Information and Links

Join the fray by commenting, tracking what others have to say, or linking to it from your blog.


Other Posts
Cristalab Colombia 2005
III Online Meeting 5dms

Write a Comment

Take a moment to comment and tell us what you think. Some basic HTML is allowed for formatting.

Reader Comments

Be the first to leave a comment!



Bad Behavior has blocked 363 access attempts in the last 7 days.