Hi Raj,
the object a don't you think to run it should extend trait a??
object a extends a {
class b extends a {
}
}
now i think even
val c:a=a will run
thanks,
SMS
On Thu, Jun 25, 2009 at 7:58 PM, Mukund Deshpande <
[email protected]> wrote:
> Hi Raj,
>
> val c:a=a
>
> what is a here??
> trait or object,
> Its trait not object so
>
> val c:a =new a
>
> when you say val c=a what gets assigned is object a
> because in scala like java class address is classn...@hashcode
> for object objectna...@hashcode
>
>
> I am not sure if it helps.
> Please tell me if i understood the whole thing wrongly.
>
> thanks,
>
> SMS
>
> On Wed, Jun 24, 2009 at 9:43 PM, rajkumargoel_786 <
> [email protected]> wrote:
>
>>
>>
>> --- In [email protected] <twincling%40yahoogroups.com>, Pratik K
>> Anand <pratik.k.an...@...> wrote:
>> >
>> > rajkumargoel_786 wrote:
>> >
>> > Now consider the case,
>> > > scala> trait a
>> > > defined trait a
>> > >
>> > > scala> object a{
>> > > | class b extends a
>> > > | }
>> > > defined module a
>> > >
>> > > scala> val c:a=a
>> > > <console>:6: error: type mismatch;
>> > > found : a.type (with underlying type object a)
>> > > required: a
>> > > val c:a=a
>> > > .....can anyone explain the reason
>> > >
>> >
>> > Interesting, this worked but i don't think this is what you asked for...
>> >
>> > pra...@pratik:~$ scala
>> > Welcome to Scala version 2.7.3final (OpenJDK Client VM, Java 1.6.0_0).
>> > Type in expressions to have them evaluated.
>> > Type :help for more information.
>> >
>> > scala> trait a
>> > defined trait a
>> >
>> > scala> object a {
>> > | class b extends a
>> > | }
>> > defined module a
>> >
>> > scala> val c=a
>> > c: a.type = a...@598d00
>> >
>> >
>> > [Non-text portions of this message have been removed]
>> >
>> HI pratik,
>> Thats fine ,but what I was asking is
>> when I specify the type to the val why does it give a error?
>> not
>> val c=a
>> but
>> val c:a=a {c of type a =a}
>>
>>
>>
>
>
[Non-text portions of this message have been removed]