Hi Raj,
If i don't add to your confusion let me tell you one thing,
if the var is val then the error that pops up is
<console>:6: error: value f is defined twice
def f {
^
thanks,
SMS
On Wed, Jun 10, 2009 at 8:55 PM, Rajkumar Goel <[email protected]
> wrote:
>
>
> 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] <saifi.khan%40twincling.org>>
> To: [email protected] <twincling%40yahoogroups.com>
> 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]
>
>
>
[Non-text portions of this message have been removed]