Skip to content

Commit 1815402

Browse files
committed
Update vim9class.{txt,jax}
1 parent 7b7be7b commit 1815402

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

doc/vim9class.jax

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -691,7 +691,13 @@ new() メソッドを使用せずにクラスを定義した場合は、自動
691691
692692
def new(this.name, this.age = v:none, this.gender = v:none)
693693
enddef
694-
< *E1328*
694+
<
695+
デフォルトの new() メソッドを使用する場合、クラス内のオブジェクト変数の順序を
696+
後で変更すると、デフォルトの new() メソッドの呼び出し元もすべて変更する必要が
697+
ある。これを回避するために、new() メソッドを引数なしで明示的に定義することがで
698+
きる。
699+
700+
*E1328*
695701
Note ここでは "v:none" 以外のデフォルト値を使用できないことに注意。オブジェク
696702
ト変数を初期化したい場合は、それらが宣言されている場所で実行すること。この方法
697703
では、デフォルト値を 1 箇所で確認するだけで済む。

en/vim9class.txt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -700,7 +700,13 @@ the name, you can define the constructor like this: >
700700
701701
def new(this.name, this.age = v:none, this.gender = v:none)
702702
enddef
703-
< *E1328*
703+
<
704+
When using the default new() method, if the order of the object variables in
705+
the class is changed later, then all the callers of the default new() method
706+
needs to change. To avoid this, the new() method can be explicitly defined
707+
without any arguments.
708+
709+
*E1328*
704710
Note that you cannot use another default value than "v:none" here. If you
705711
want to initialize the object variables, do it where they are declared. This
706712
way you only need to look in one place for the default values.

0 commit comments

Comments
 (0)