Item (Arraylist property): Difference between revisions

From m204wiki
Jump to navigation Jump to search
(Created page with "<span style="font-size:120%; color:black"><b><section begin=dpl_desc/>Return or set Arraylist item value<section end=dpl_desc/></b></span> [[Category:Arraylist methods|Item prope...")
 
 
(24 intermediate revisions by 5 users not shown)
Line 1: Line 1:
<span style="font-size:120%; color:black"><b><section begin=dpl_desc/>Return or set Arraylist item value<section end=dpl_desc/></b></span>
{{Template:Arraylist:Item subtitle}}
[[Category:Arraylist methods|Item property]]
<var>Item</var> is a <var>ReadWrite</var> property that 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"]].
<!--DPL?? Category:Arraylist methods|Item property: Return or set Arraylist item value-->
<p>
Item is a member of the [[Arraylist class]].
</p>


This ReadWrite property
==Syntax==
returns or sets the indicated item in the Arraylist.
{{Template:Arraylist:Item syntax}}
===Syntax terms===
<table class="syntaxTable">
<tr><th>%currentItem</th>
<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.</td></tr>
<tr><th>al</th>
<td>An <var>Arraylist</var> object. </td></tr>
<tr><th>number</th>
<td>A whole number greater than 0 to identify an <var class="term">al</var> item by its position within the arraylist. If <var class="term">number</var> 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>
<tr><th>newItem</th>
<td>A 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>
</table>


For additional description of this method, see [[Collections#Coding considerations for collections|Coding considerations for collections]].
==Usage notes==
===Syntax===
<ul>
  %item = %arrayl:Item(number)
<li>The <code><var>Item</var></code> keyword is not required.  For instance, in the <var>For</var> loop in the [[Arraylist class]] example, <code>print %alist(%i)</code> is equivalent to:
<p class="code">print %alist:<var>Item</var>(%i)
</p>
<li>Explicitly references to retrieve or set just the first or last item in an <var>Arraylist</var> can be done via <var>[[FirstItem (Arraylist property)|FirstItem]]</var> or <var>[[LastItem (Arraylist property)|LastItem]]</var> respectively.</ul>


  %arrayl:Item(number) = %item
==See also==
====Syntax Terms====
{{Template:Arraylist:Item footer}}
<dl>
<dt><i>%item</i>
<dd>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.
<dt><i>%arrayl</i>
<dd>An Arraylist object.
<dt><i>number</i>
<dd>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.
 
</dl>
===Usage Notes===
<ul>
<li>The <tt>Item</tt>  keyword is not required.
For instance, in the For loop in the
[[Arraylist class]] example, <tt>print %alist(%i)</tt> is equivalent to:
<pre style="xmp">
    print %alist:Item(%i)
</pre>
<li>Methods are available to retrieve or seet the first or just the last item in
an Arraylist.
See [[FirstItem (Arraylist property)|FirstItem]] and [[LastItem (Arraylist property)|LastItem]].
</ul>

Latest revision as of 15:44, 1 November 2012

Return or set Arraylist item value (Arraylist class)

Item is a ReadWrite property that 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

%currentItem A variable of the same type as specified on the al declaration to contain the value of the specified al item.
al An Arraylist object.
number A whole number greater than 0 to identify an al item by its position within 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.
newItem A value of the same type as specified on the al declaration to be assigned to the specified al item.

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:Item(%i)

  • Explicitly references to retrieve or set just the first or last item in an Arraylist can be done via FirstItem or LastItem respectively.

See also