The tag <stack.peek> returns the last object stored in the stack without removing it from it. The stack can be indicated via the
attribute name or passing it as argument.
1 stack.peek
<stack.peek name='name'>
<stack /> ?
</stack.peek>
Attributes | |||||
---|---|---|---|---|---|
Name | Type | Required | Default | Description | |
Aname | string | Stack name. |
Arguments | |||||
---|---|---|---|---|---|
Name | Type | Required | Unique | Nullable | Description |
Estack | Stack |
Returns | |
---|---|
Type | Description |
Object | The last object which has been placed in the stack. |
Example
Initialize the execution stack with two values and obtain them through the tag stack.peek.
Copy
<xsql-script name='peek_test'> <body> <stack name='stack1'><number>10</number><string>hello</string></stack> <!-- The stack is not altered --> <set name='a'><stack.peek name='stack1' /></set> <println><a/></println> <!-- hello --> <!-- Extraction of the object which is in the top of the stack, it is the same than before because the peek does not remove the stack. --> <set name='b'><stack.peek><stack1/></stack.peek></set> <println><b/></println> <!-- hello --> </body> </xsql-script>