|
|
Re: Chapter 17, Section 4
|
Posted: Jan 29, 2008 6:34 PM
|
|
> I dont understand this code: > > def append[U >: T](x: Y) = > new Queue(leading, x :: trailing) > > What is the meaning of Y? Shouldn it be U instead?
Yes it should be U.
Similarly, in Figure 17.1 def append[T](x: t) should be def append[T](x: T)
Also, when I tried to compile Figure 17.1, I needed to change class Queue[+T](leading: List[T], trailing: List[T]) to class Queue[T](val leading: List[T], val trailing: List[T])
I'm not up to chapter 17 in my reading yet, so I'll leave it at that for now.
|
|