-
Notifications
You must be signed in to change notification settings - Fork 72
4.15. Method Syntax #22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…into 4_15_Method_Syntax
…into 4_15_Method_Syntax
`self`, `&self`, and `&mut self`. You can think of this first parameter as | ||
being the `foo` in `foo.bar()`. The three variants correspond to the three | ||
kinds of things `foo` could be: `self` if it’s just a value on the stack, | ||
`&self` if it’s a reference, and `&mut self` if it’s a mutable reference. | ||
Because we took the `&self` parameter to `area`, we can use it just like any | ||
other parameter. Because we know it’s a `Circle`, we can access the `radius` | ||
just like we would with any other `struct`. | ||
just like we would with any other `struct`. --> | ||
メソッドに渡す特別な第1引数として、 `self` 、 `&self` 、 `&mut self` という3つの変形があります。 `foo.bar()` の第1引数は `foo` であると考えて下さい。3つの変形は `foo` が成り得る3種類の状態に対応しており、それぞれ `self` がスタック上の値である場合、 `&self` が参照である場合、 `&mut self` がミュータブルな参照である場合となっています。 `area` で `&self` を受け取っているため、他の引数と同じように扱えます。引数が `Circle` であるのは分かっていますから、他の `struct` でするように `radius` へアクセスできます。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
foo.bar()
の第1引数は
foo` であると考えて下さい
原文の"You can think of this first parameter as being the foo
in foo.bar()
."とはやや異なっているように感じます。
「第一引数はfoo.bar()
に於けるfoo
と思って下さい」はどうでしょうか。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nits]
area
で
「area
では」の方がやや読みやすいかと。
コメントしました。[WIP]を外したらpingを飛ばしていただけるとレビューが早くなります。 |
variantsは例えば文字なら「異体字」などと訳されるのですが上手い和訳が思いつきませんね…。「変形」でいいと思います。
"associated ~"については"associated type"に「関連型」という定訳があるようなのでそこから援用しています。「関連関数」で良いと思います。 |
@KeenS レビューの反映完了しました、宜しくお願いします。 |
長くかかってしましましたがお疲れさまでした。ありがとうございます。 |
@KeenS すみません、成果物のインデックスだと「メソッド構文」になっていました、私の訳のタイトルが「メソッドシンタックス」なので修正しなければなりません… |
おや、本当ですね。軽微なので手元で修正します。 |
ありがとうございます。 |
Qiitaより移転。
暫定翻訳完了しました