mirror of
https://github.com/erg-lang/erg.git
synced 2025-08-04 10:49:54 +00:00
Update docs
This commit is contained in:
parent
00c05ab668
commit
6fd9ce2650
2 changed files with 12 additions and 14 deletions
|
@ -34,13 +34,7 @@ f some_long_name_variable_1 + some_long_name_variable_2:
|
|||
some_long_name_variable_3 * some_long_name_variable_4
|
||||
```
|
||||
|
||||
```python
|
||||
f:
|
||||
some_long_name_variable_1 + some_long_name_variable_2
|
||||
some_long_name_variable_3 * some_long_name_variable_4
|
||||
```
|
||||
|
||||
上の3つのコードはすべて同じ意味です。このスタイルは`if`関数などを使用するときにも便利です。
|
||||
上の2つのコードは同じ意味です。このスタイルは`if`関数などを使用するときにも便利です。
|
||||
|
||||
```python
|
||||
result = if Bool.sample!():
|
||||
|
@ -52,7 +46,15 @@ result = if Bool.sample!():
|
|||
0
|
||||
```
|
||||
|
||||
`:`の後はコメント以外のコードを書いてはならず、必ず改行しなくてはなりません。
|
||||
この場合、`:`の後はコメント以外のコードを書いてはならず、必ず改行しなくてはなりません。
|
||||
また、関数の直後に`:`を使うことはできません。これができるのは`do`と`do!`のみです。
|
||||
|
||||
```python
|
||||
# NG
|
||||
f:
|
||||
x
|
||||
y
|
||||
```
|
||||
|
||||
## キーワード引数(Keyword Arguments)
|
||||
|
||||
|
|
|
@ -4,15 +4,11 @@ s = if cond:
|
|||
do "else block"
|
||||
assert s == "then block"
|
||||
|
||||
# else: binary operator
|
||||
x = cond.then 1 else 2
|
||||
assert x == 1
|
||||
|
||||
if! cond:
|
||||
do!:
|
||||
print! "then block"
|
||||
print! "then block!"
|
||||
do!:
|
||||
print! "else block"
|
||||
print! "else block!"
|
||||
|
||||
a = [1, 2, 3]
|
||||
sum = match a:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue