In Scala for the Intolerant, the author provides the following two examples for โunderstandingโ:
for (c <- "Hello"; i <- 0 to 1) yield (c + i).toChar // Yields "HIeflmlmop" for (i <- 0 to 1; c <- "Hello") yield (c + i).toChar // Yields Vector('H', 'e', 'l', 'l', 'o', 'I', 'f', 'm', 'm', 'p')
However, he did not mention why the output is a string in the first case, and Vector in the second. Can anyone explain this? Thanks.
source share