Core Function Ref
From Sputnik Wiki
(Difference between revisions)
(Created page with "<pre> Ref( $variable ) </pre> === Description === Retrieve the variable at the lowest depth in references that the current variable links to === Parameters === ==== $variable...") |
(→Example) |
||
Line 30: | Line 30: | ||
println( isVarRef( $b ) ? "true" : "false" ); | println( isVarRef( $b ) ? "true" : "false" ); | ||
println( isVarRef( Ref($b) ) ? "true" : "false" ); | println( isVarRef( Ref($b) ) ? "true" : "false" ); | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | The * operator can also be used as if Ref() was used example : | ||
+ | <syntaxhighlight lang="sputnik"> | ||
+ | $a = qw(The quick brown fox); | ||
+ | $b = &$a; | ||
+ | println( isVarRef( $b ) ? "true" : "false" ); | ||
+ | println( isVarRef( *$b ) ? "true" : "false" ); | ||
</syntaxhighlight> | </syntaxhighlight> | ||
[[Category:Core Function]] | [[Category:Core Function]] |
Revision as of 13:35, 10 August 2013
Ref( $variable )
Contents |
Description
Retrieve the variable at the lowest depth in references that the current variable links to
Parameters
$variable
A variable to locate and return its ref.
(If the variable links to a ref that links to a ref that links to a ref it will return the last one it finds at the end of the chain assuming the chain does end... )
Return Value
None
Remarks
None.
Example
$a = qw(The quick brown fox); $b = &$a; println( isVarRef( $b ) ? "true" : "false" ); println( isVarRef( Ref($b) ) ? "true" : "false" );
The * operator can also be used as if Ref() was used example :
$a = qw(The quick brown fox); $b = &$a; println( isVarRef( $b ) ? "true" : "false" ); println( isVarRef( *$b ) ? "true" : "false" );