The Artima Developer Community
Sponsored Link

Programming in Scala Forum
Chapter 17, Section 4

1 reply on 1 page. Most recent reply: Jan 29, 2008 6:34 PM by Eric Willigers

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 1 reply on 1 page
Juan Miguel Garcia Lopez

Posts: 4
Nickname: sammalone
Registered: Dec, 2007

Chapter 17, Section 4 Posted: Jan 7, 2008 11:41 AM
Reply to this message Reply
Advertisement
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?


Eric Willigers

Posts: 8
Nickname: ewilligers
Registered: Dec, 2007

Re: Chapter 17, Section 4 Posted: Jan 29, 2008 6:34 PM
Reply to this message Reply
> 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.

Flat View: This topic has 1 reply on 1 page
Topic: Please add some code with Mutidimensional arrays Previous Topic   Next Topic Topic: Functions and Closures: withPrintWriter

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use