You are viewing an older version of the site. Click here to view
the latest version of this page. (This may be a dead link, if so, try the root page of the docs
here.)
== postinc ==
Copy Code
The output would be:
Copy Code
The output would be:
Copy Code
The output would be:
Adds x to var, and stores the new value. Equivalent to var++ in other languages. Expects ivar to be a variable, then returns a copy of the old ivar, or, if var is a constant number, simply adds x to it, and returns the new number. Operator notation is also supported: @var++
=== Vital Info ===
{| style="width: 40%;" cellspacing="1" cellpadding="1" border="1" class="wikitable"
|-
! scope="col" width="20%" |
! scope="col" width="80%" |
|-
! scope="row" | Name
| postinc
|-
! scope="row" | Returns
| ivar
|-
! scope="row" | Usages
| var, [x]
|-
! scope="row" | Throws
| [[../objects/ms.lang.CastException|ms.lang.CastException]]
|-
! scope="row" | Since
| 3.3.1
|-
! scope="row" | Restricted
| No
|-
! scope="row" | Optimizations
| [[../../Optimizer#OPTIMIZE_CONSTANT|OPTIMIZE_CONSTANT]]
|}
=== Usages ===
postinc(var, [x])=== Examples === ====Example 1==== Basic functional usage Given the following code:
@a = 5;
msg(postinc(@a));
msg(@a);

1 @a = 5;
2 {{function|msg}}({{function|postinc}}(@a));
3 {{function|msg}}(@a);
5 6====Example 2==== Basic functional usage, with optional value set Given the following code:
@a = 5;
msg(postinc(@a, 6));
msg(@a);

1 @a = 5;
2 {{function|msg}}({{function|postinc}}(@a, 6));
3 {{function|msg}}(@a);
5 11====Example 3==== Operator syntax Given the following code:
@a = 5;
msg(@a++);
msg(@a);

1 @a = 5;
2 {{function|msg}}(@a++);
3 {{function|msg}}(@a);
5 6===See Also===
[[API/functions/postdec.html|postdec]]
, [[API/functions/inc.html|inc]]
, [[API/functions/dec.html|dec]]
Find a bug in this page? Edit this page yourself, then submit a pull request. (Note this page is automatically generated from the documentation in the source code.)