But f is a feild and in the next line it is a method. But the error is that both f are methods.
________________________________ From: Saifi Khan <[email protected]> To: [email protected] Sent: Thursday, 11 June, 2009 2:20:59 AM Subject: Re: [twincling] [observation-scala] On Wed, 10 Jun 2009, Rajkumar Goel wrote: > Hi all, > This is what the error I got when I wrote the following code in SCALA. > scala> class Wont{ > | private var f=0; > | def f=1; > | } > <console>:6: error: method f is defined twice > def f=1; > ie., it is treating a feild also a method. > Any pointers ???Why such behavior. > Thanks, > RajkumarGoel > The first line is private var f = 0; Here the identifier 'f' is seen first and the 'var' means the type is not known. However, the =0 causes the "type inference" machinery to kick and specify the 'type' for f as 'Int'. With this 'f' is declared and defined. The next line is again an attempt to define 'f'. Hence the error. thanks Saifi. ------------------------------------ IRC #twincling on irc.freenode.net Yahoo! Groups Links Explore your hobbies and interests. Go to http://in.promos.yahoo.com/groups/ [Non-text portions of this message have been removed]

