I am currently studying Scala, working through the book "Scala Programming." So far, there has been a good explanation of everything that looks weird (from the perspective of a Java programmer), but this one example of using Stream to generate a Fibonacci sequence leaves me puzzled:
def fibFrom(a: Int, b: Int): Stream[Int] = a
How is the Stream built? Of course, the #::
operator is somehow responsible for this. I understand that since it ends with :
it is right-associative, but that does not explain the creation of Stream. I assume that this is implicitly translated to the constructor, but I donβt understand why and how.
I already searched for the answers in Predef.scala
and LowPriorityImplicits.scala
, but so far no luck.
Can someone enlighten me?
rolve source share