The Artima Developer Community
Sponsored Link

Programming in Scala Forum
eBook take 2: why not class Rational(numer: Int, ...?

2 replies on 1 page. Most recent reply: Mar 3, 2008 7:38 PM by Howard Lovatt

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 2 replies on 1 page
Rob Dickens

Posts: 15
Nickname: robcd
Registered: Feb, 2008

eBook take 2: why not class Rational(numer: Int, ...? Posted: Feb 24, 2008 9:38 AM
Reply to this message Reply
Advertisement
I'm referring to the first version of this class, as given on page 138:
class Rational(n: Int, d: Int) { 
val numer: Int = n
val denom: Int = d
def ...

I was lead (page 79) to believe that class params become fields (if they're used), so why doesn't the following compile?:
class Rational(numer: Int, denom: Int) { 
def ...


Rob Dickens

Posts: 15
Nickname: robcd
Registered: Feb, 2008

Re: eBook take 2: why not class Rational(numer: Int, ...? Posted: Feb 27, 2008 12:56 PM
Reply to this message Reply
Is there anybody out there?

Okay, so Rational(val numer: Int, ... works (as explained on p213).

Howard Lovatt

Posts: 321
Nickname: hlovatt
Registered: Mar, 2003

Re: eBook take 2: why not class Rational(numer: Int, ...? Posted: Mar 3, 2008 7:38 PM
Reply to this message Reply
There is a discussion of this already:

http://www.artima.com/forums/flat.jsp?forum=282&thread=221117

Flat View: This topic has 2 replies on 1 page
Topic: certmagic.com ? Previous Topic   Next Topic Topic: Lazy evaluation / Futures?

Sponsored Links



Google
  Web Artima.com   

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