mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-20 11:30:18 +00:00
Create incdec.md
This commit is contained in:
parent
a4eecdaa84
commit
f8ce2e3849
23
docs/features/incdec.md
Normal file
23
docs/features/incdec.md
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
---
|
||||||
|
icon: dot
|
||||||
|
title: Increment Statement
|
||||||
|
---
|
||||||
|
|
||||||
|
pkpy provides `++i` and `--j` statements to operate a simple named `int` variable.
|
||||||
|
|
||||||
|
+ `++i` is equivalent to `i+=1`, but much faster
|
||||||
|
+ `--j` is equivalent to `j-=1`, but much faster
|
||||||
|
|
||||||
|
## Example
|
||||||
|
|
||||||
|
```python
|
||||||
|
a = 1
|
||||||
|
++a
|
||||||
|
assert a == 2
|
||||||
|
|
||||||
|
def f(a):
|
||||||
|
--a
|
||||||
|
return a
|
||||||
|
|
||||||
|
assert f(3) == 2
|
||||||
|
```
|
Loading…
x
Reference in New Issue
Block a user