The Artima Developer Community
Sponsored Link

Programming in Scala Forum
Duplication in Chapter 8?

0 replies on 1 page.

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 0 replies on 1 page
Ravi Mohan

Posts: 11
Nickname: ravim
Registered: Jan, 2003

Duplication in Chapter 8? Posted: Feb 17, 2008 1:15 AM
Reply to this message Reply
Advertisement
hello,

end of page 159

" For example, the curried version of withPrintWriter looks like this:
def withPrintWriter(file: File)(operation: PrintWriter => Unit) {
val writer = new PrintWriter(f)
try {
operation(writer)
} finally {
writer.close()
}
}"


After one paragraph, in page 160, we see


Here is an implementation of withPrintWriter that supports this:

"
def withPrintWriter(f: File)(op: PrintWriter => Unit) {
val writer = new PrintWriter(f)
try {
op(writer)
} finally {
writer.close()
}
}
"


Aren't these definitions exactly the same, except for the substitution of "op" for "operator" ? I think the latter could be removed and the flow would be intact.

Regards,
Ravi

Topic: Suggestion for Chapter 10 Previous Topic   Next Topic Topic: I think you kill 2 birds not 2 flies

Sponsored Links



Google
  Web Artima.com   

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