Item (Arraylist property): Difference between revisions

From m204wiki
Jump to navigation Jump to search
m (1 revision)
m (1 revision)
Line 1: Line 1:
{{Template:Arraylist:Item subtitle}}
{{Template:Arraylist:Item subtitle}}
[[Category:Arraylist methods|Item property]]
[[Category:Arraylist methods|Item property]]
<!--DPL?? Category:Arraylist methods|<var>Item</var> property: Return or set Arraylist item value-->
<!--DPL?? Category:<var>Arraylist</var> methods|<var>Item</var> property: Return or set <var>Arraylist</var> item value-->
<p>
<p>
<var>Item</var> is a member of the [[Arraylist class]].
<var>Item</var> is a member of the [[Arraylist class]].
Line 7: Line 7:


This ReadWrite property
This ReadWrite property
returns or sets the indicated item in the Arraylist.
returns or sets the indicated item in the <var>Arraylist</var>.


For additional description of this method, see [[Collections#Coding considerations for collections|Coding considerations for collections]].
For additional description of this method, see [[Collections#Coding considerations for collections|Coding considerations for collections]].
Line 15: Line 15:
<table class="syntaxTable">
<table class="syntaxTable">
<tr><th><i>%item</i></th>
<tr><th><i>%item</i></th>
<td>A variable of the same type as specified on the ''%arrayl'' declaration to contain the value of the specified ''%arrayl'' item. Or a variable or value of the same type as specified on the ''%arrayl'' declaration to be assigned to the specified ''%arrayl'' item. </td></tr>
<td>A variable of the same type as specified on the ''<var class="term">al</var>'' declaration to contain the value of the specified ''<var class="term">al</var>'' item. Or a variable or value of the same type as specified on the ''<var class="term">al</var>'' declaration to be assigned to the specified ''<var class="term">al</var>'' item. </td></tr>
<tr><th><i>%arrayl</i></th>
<tr><th><i><var class="term">al</var></i></th>
<td>An Arraylist object. </td></tr>
<td>An <var>Arraylist</var> object. </td></tr>
<tr><th><i>number</i></th>
<tr><th><i>number</i></th>
<td>A whole number greater than 0 to identify an ''%arrayl'' item by its position in the arraylist. If ''number'' is greater than the number of items in the ''%arrayl'', or if it is less than or equal to zero, the request is cancelled.</td></tr>
<td>A whole number greater than 0 to identify an ''<var class="term">al</var>'' item by its position in the arraylist. If ''number'' is greater than the number of items in the ''<var class="term">al</var>'', or if it is less than or equal to zero, the request is cancelled.</td></tr>
</table>
</table>
==Usage notes==
==Usage notes==
Line 30: Line 30:
</pre>
</pre>
<li>Methods are available to retrieve or seet the first or just the last item in
<li>Methods are available to retrieve or seet the first or just the last item in
an Arraylist.
an <var>Arraylist</var>.
See [[FirstItem (Arraylist property)|FirstItem]] and [[LastItem (Arraylist property)|LastItem]].
See [[FirstItem (Arraylist property)|FirstItem]] and [[LastItem (Arraylist property)|LastItem]].
</ul>
</ul>

Revision as of 02:29, 20 January 2011

Return or set Arraylist item value (Arraylist class)

Item is a member of the Arraylist class.

This ReadWrite property returns or sets the indicated item in the Arraylist.

For additional description of this method, see Coding considerations for collections.

Syntax

%currentItem = al:Item( number) al:Item( number) = newItem

Syntax terms

%item A variable of the same type as specified on the al declaration to contain the value of the specified al item. Or a variable or value of the same type as specified on the al declaration to be assigned to the specified al item.
al An Arraylist object.
number A whole number greater than 0 to identify an al item by its position in the arraylist. If number is greater than the number of items in the al, or if it is less than or equal to zero, the request is cancelled.

Usage notes

  • The Item keyword is not required. For instance, in the For loop in the Arraylist class example, print %alist(%i) is equivalent to:
        print %alist:<var>Item</var>(%i)
    
  • Methods are available to retrieve or seet the first or just the last item in an Arraylist. See FirstItem and LastItem.