Skip to content

Add minor explanation about List are homogeneous #56

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 1 commit into from
Mar 9, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/main/scala/scalatutorial/sections/StandardLibrary.scala
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,14 @@ object StandardLibrary extends ScalaTutorialSection {
*
* - Lists are immutable --- the elements of a list cannot be changed,
* - Lists are recursive (as you will see in the next subsection),
* - Lists are ''homogeneous'': the elements of a list must all have the
* same type.
* - Lists are ''homogeneous'': A list is intended to be composed of elements that all have the same type.
*
* That's because when you create a `List` of elements with different types it will look for a common ancestor.
* The common ancestor for all types is `Any`
*
* {{{
* val heterogeneousList: List[Any] = List(1, "1", '1')
* }}}
*
* The type of a list with elements of type `T` is written `List[T]`:
*
Expand Down