Swapping Values

VERSION 4 Published

Created on:Sep 27, 2007 10:13 AM by curl - Last Modified:  Sep 27, 2007 5:09 PM by curl

Posted: Wed May 09, 2007 2:11 pm
cbarber

Starting with Curl 4.0, you can use 'tuple' syntax to swap values without an explicit temporary value:

Code: 
set (a, b) = (b, a) 


This syntax is also useful to supply default values from a conditional when the other branches produce multiple values:

Code: 
let (x:double, y:double) = 
   {if call-function? then 
       {get-coordinates} 
    else 
       (0.0, 0.0) 
   } 
Average User Rating
(0 ratings)




There are no comments on this document