Show page source of JavaFXReference_06_09_UnaryExpression #43954

= 単項式
----
'''図 6.27. 単項式'''[[BR]]
{{{
接尾式 | 'indexof' 識別子 | {'-' | 'not' | 'sizseof' | '++' | '--' | 'reverse'} 単項式 }
}}}

'''表 6.7. 接頭単項演算子'''[[BR]]
{{{ html
<table summary="Prefix Unary Operator" border="1">
<colgroup><col align="center"><col><col><col></colgroup>
<thead><tr><th align="center">演算子</th><th align="center">意味</th><th align="center">演算対象の型</th><th align="center">処理結果の型</th></tr></thead>
<tbody>
<tr><td rowspan="3" align="center"><span class="command"><strong>-</strong></span></td><td rowspan="3">否定</td><td><span class="command"><strong>-</strong></span> Integer</td><td>Integer</td></tr>
<tr><td><span class="command"><strong>-</strong></span> Number</td><td>Number</td></tr>
<tr><td><span class="command"><strong>-</strong></span> Duration</td><td>Duration</td></tr>
<tr><td align="center"><span class="command"><strong>not</strong></span></td><td>論理否定</td><td><span class="command"><strong>not</strong></span> Boolean</td><td>Boolean</td></tr>
<tr><td align="center"><span class="command"><strong>sizeof</strong></span></td><td>配列の要素の数</td><td><span class="command"><strong>sizeof</strong></span> Object</td><td>Integer</td></tr>
<tr><td align="center"><span class="command"><strong>reverse</strong></span></td><td>配列の要素を反転する</td><td><span class="command"><strong>reverse</strong></span> Object</td><td>Object</td></tr>
<tr><td rowspan="2" align="center"><span class="command"><strong>++</strong></span></td><td rowspan="2">演算対象に1を加えて値を更新する</td><td><span class="command"><strong>++</strong></span> Integer</td><td>Integer</td></tr>
<tr><td><span class="command"><strong>++</strong></span> Number</td><td>Number</td></tr><tr><td rowspan="2" align="center"><span class="command"><strong>--</strong></span></td><td rowspan="2">演算対象から1を減じて値を更新する</td><td><span class="command"><strong>--</strong></span> Integer</td><td>Integer</td></tr>
<tr><td><span class="command"><strong>--</strong></span> Number</td><td>Number</td></tr>
<tr><td align="center"><span class="command"><strong>indexof</strong></span></td><td>反復している配列の現在の位置</td><td>n/a</td><td>Integer</td></tr>
</tbody>
</table>
}}}

この例は3つの配列の演算子を実演します。
{{{
def endangered = ['Caribou', 'Ocelot', 'Puma', 'Sei'];
println( endangered );
def flipped = reverse endangered;
println( flipped );
println( sizeof endangered );
for (mammal in endangered) {
   println( 'Mammal #{ indexof mammal } is { mammal }' );
}
}}}

コンソールは次のようになります。
{{{
[ Caribou, Ocelot, Puma, Sei ]
[ Sei, Puma, Ocelot, Caribou ]
4 
Mammal #0 is Caribou 
Mammal #1 is Ocelot 
Mammal #2 is Puma 
Mammal #3 is Sei
}}}

[[PageNavi(JavaFXReference_00_01_TableOfContents)]]
[[include(JavaFXReference_00_02_Footer)]]