Link | cast |
Author | Jason Huck |
Category | Variable |
Version | 8.x |
License | http://opensource.org/licenses/artistic-license.php |
Posted | 13 Feb 2006 |
Updated | 13 Feb 2006 |
More by this author... |
This is a shortcut to programmatically re-cast an element to a new type.
// testing var('types') = array( 'array', 'boolean', 'bytes', 'date', 'decimal', 'duration', 'integer', 'map', 'pair', 'string', ); iterate($types, local('t')); var('foo' = '2'); cast($foo, -as=#t); $foo + ': ' + $foo->type; '
\n'; /iterate; '
\n'; var('bar' = ''); $bar->type; ' hi
\n'; cast($bar, -as='xml'); $bar->type;
Click the "Download" button below to retrieve a copy of this tag, including the complete documentation and sample usage shown on this page. Place the downloaded ".inc" file in your LassoStartup folder, restart Lasso, and you can begin using this tag immediately.
define_tag( 'cast', -required='in', -required='as', -priority='replace', -description='Casts the given object as the given type.' ); protect; if(#as == 'bytes'); local('x' = bytes); #x->importstring(string(#in)); #in = #x; else; #in = tags->find(#as)->run( -params=array(#in) ); /if; /protect; /define_tag;
©LassoSoft Inc 2015 | Web Development by Treefrog Inc | Privacy | Legal terms and Shipping | Contact LassoSoft
Using Cast to dynamically assign and execute types and methods.