Skip to content

Commit 423b3d9

Browse files
committed
Update by original
1 parent ef976bd commit 423b3d9

2 files changed

Lines changed: 25 additions & 17 deletions

File tree

doc/vim9.jax

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1073,8 +1073,11 @@ For ループ ~
10731073
special true または v:true
10741074
job 非 NULL
10751075
channel 非 NULL
1076-
class 非 NULL
1077-
object 非 NULL (TODO: isTrue() が true を返すとき)
1076+
class 該当なし
1077+
object 非 NULL
1078+
enum 該当なし
1079+
enum value 常時
1080+
typealias 該当なし
10781081

10791082
真偽値演算子 "||" と "&&" は、値が真偽値、0 または 1 であることを期待する: >
10801083
1 || false == true
@@ -2350,11 +2353,12 @@ script と Vim9 script の両方で、辞書以外の値が必要なときに、
23502353
# あると推測する
23512354
map(mylist, (i, _) => $"item {i}") # E1012: type mismatch...
23522355
<
2353-
The error occurs because `map()` tries to modify the list elements to strings,
2354-
which conflicts with the declared type.
2356+
このエラーは、`map()` がリスト要素を文字列に変更しようとし、宣言された型と衝突
2357+
するために発生する。
23552358

2356-
Use |mapnew()| instead. It creates a new list, and Vim infers its type if it
2357-
is not specified. Inferred and declared types are shown in this example: >vim9
2359+
代わりに |mapnew()| を使用する。これは新しいリストを作成し、型が指定されていな
2360+
い場合は Vim がその型を推測する。推測された型と宣言された型は以下の例のとおり
2361+
である: >vim9
23582362

23592363
vim9script
23602364
var mylist = [0, 1]
@@ -2363,18 +2367,18 @@ is not specified. Inferred and declared types are shown in this example: >vim9
23632367
var declare: list<string> = mylist->mapnew((i, _) => $"item {i}")
23642368
echo [declare, declare->typename()]
23652369
<
2366-
The key concept here is, variables with declared or inferred types cannot
2367-
have the types of the elements within their containers change. However, type
2368-
"changes" are allowed for either:
2369-
- a container literal (not bound to a variable), or
2370-
- a container where |copy()| or |deepcopy()| is used in method chaining.
2371-
Both are demonstrated in this example: >vim9
2370+
ここで重要な概念は、宣言型または推論型を持つ変数では、コンテナ内の要素の型は変
2371+
更できないということである。ただし、以下のいずれかの場合は型の "変更" が許容さ
2372+
れる:
2373+
- コンテナリテラル (変数に束縛されていない)、または
2374+
- メソッドチェーンで |copy()| または |deepcopy()| が使用されているコンテナ。
2375+
この例では、どちらも示されている: >vim9
23722376

23732377
vim9script
2374-
# list literal
2378+
# 文字列のリスト
23752379
echo [1, 2]->map((_, v) => $"#{v}")
23762380
echo [1, 2]->map((_, v) => $"#{v}")->typename()
2377-
# deepcopy() in a method chain
2381+
# メソッド チェーン内の deepcopy()
23782382
var mylist = [1, 2]
23792383
echo mylist->deepcopy()->map((_, v) => $"#{v}")
23802384
echo mylist->deepcopy()->map((_, v) => $"#{v}")->typename()

en/vim9.txt

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1084,8 +1084,11 @@ empty list and dict is falsy:
10841084
special true or v:true
10851085
job when not NULL
10861086
channel when not NULL
1087-
class when not NULL
1088-
object when not NULL (TODO: when isTrue() returns true)
1087+
class not applicable
1088+
object when not NULL
1089+
enum not applicable
1090+
enum value always
1091+
typealias not applicable
10891092

10901093
The boolean operators "||" and "&&" expect the values to be boolean, zero or
10911094
one: >
@@ -3400,7 +3403,8 @@ much overhead that cannot be avoided.
34003403
Therefore the `:def` method to define a new-style function had to be added,
34013404
which allows for a function with different semantics. Most things still work
34023405
as before, but some parts do not. A new way to define a function was
3403-
considered the best way to separate the legacy style code from Vim9 style code.
3406+
considered the best way to separate the legacy style code from Vim9 style
3407+
code.
34043408

34053409
Using "def" to define a function comes from Python. Other languages use
34063410
"function" which clashes with legacy Vim script.

0 commit comments

Comments
 (0)