Skip to content

Subsection for Immutability and Variance #2468

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

Merged
merged 2 commits into from
Nov 9, 2022
Merged

Conversation

KarahanS
Copy link
Contributor

Proposed the addition of a subsection to Variance explaining the relationship between immutability and variance very briefly with an example. Referenced the related part of the document for immutable/mutable classes. Compared two Collections, List and Array to show why one is covariant while the other is invariant.
Based on the discussion Why are Arrays invariant, but Lists covariant?.

Copy link
Member

@bishabosha bishabosha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @KarahanS, I'm sorry it took so long to review. Array is a bit of a special case in Scala so I changed to ListBuffer as it is closer to something the user can write themselves.

@bishabosha bishabosha merged commit 5bfd57c into scala:main Nov 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants