変性の説明と型定義の対応を修正しました。 - #1138
Merged
Merged
Conversation
## 対象者 - [x] 📖 読者 ## Problem 変性の説明では引数`I`を共変、戻り値`O`を反変としていました。一方で直後の型定義では、戻り値`O`に`out`、引数`I`に`in`を指定していました。説明とコード例が逆になっており、読者が変性を誤って理解する可能性がありました。 ## Solution `CovariantFunction<I, out O>`と`ContravariantFunction<in I, O>`の型定義に合わせて、戻り値`O`が共変、引数`I`が反変であることを説明しました。 ## Value 読者が`out`による共変性と`in`による反変性を、コード例と対応付けて理解できるようになります。 --- close #1137
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
対象者
Problem
変性の説明では引数
Iを共変、戻り値Oを反変としていました。一方で直後の型定義では、戻り値Oにout、引数Iにinを指定していました。説明とコード例が逆になっており、読者が変性を誤って理解する可能性がありました。Solution
CovariantFunction<I, out O>とContravariantFunction<in I, O>の型定義に合わせて、戻り値Oが共変、引数Iが反変であることを説明しました。Value
読者が
outによる共変性とinによる反変性を、コード例と対応付けて理解できるようになります。close #1137