Answer the question
In order to leave comments, you need to log in
Scala Stream
Can someone explain this aspect of how threads work?
scala> 1 #:: (null:Stream[Int])
res5: scala.collection.immutable.Stream[Int] = Stream(1, ?)
If op is right-associative, the same operation is interpreted as { val x = e1; e2.op(x) }, where x is a fresh name.
Two methods in class List which are not supported by class Stream are :: and :::. The reason is that these methods are dispatched on their right-hand side argument, which means that this argument needs to be evaluated before the method is called. ... Instead of x :: xs, one uses Stream.cons(x, xs) for constructing a stream with first element x and (unevaluated) rest xs.
Answer the question
In order to leave comments, you need to log in
6.12.3 has nothing to do with #::. It's more about list operations ::, :::. In scala, if a statement starts with: it automatically becomes right associative and is executed from the right argument.
1 :: 2 :: 3 :: Nil // List[Int]().::(3).::(2).::(1)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question