KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
Following Scala courses on Coursera, Martin Odersky showed an example code which is: 1 to 5 map ( i => i*i ) And he said the Range gets transformed to a Vector because they share the same interface ( IndexedSeq ) and the result could not be represented as a Range (it was more clear in its example since he generated a pair which is not representable as a Range ). I'm not sure to understand because I think he said previously that in a for expression the 1st generator will determine the kind of element that will be yielded, and it seems not always true, at least for Range . And I'm not sure to understand why the output is Vector , because Vector may not be the only other one implementation that can represent the result computed above. Can someone help me understand this part please?
Tags (comma-separated)
Save Edits
Cancel