List[Nothing] and object Nil

View: New views
5 Messages — Rating Filter:   Alert me  

List[Nothing] and object Nil

by Mukund :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi all,

scala> val empty=Nil::Nil
empty: List[object Nil] = List(List())

scala> empty.head
res11: object Nil = List()

scala> val empty=List()::List()
empty: List[List[Nothing]] = List(List())

scala> empty.head
res14: List[Nothing] = List()

So is List[Nothing] and object Nil ..similar?

thanks,

SMS


[Non-text portions of this message have been removed]


Re: List[Nothing] and object Nil

by rajkumargoel_786 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

--- In twincling@..., Mukund Deshpande <mukund.twincling@...> wrote:

>
> Hi all,
>
> scala> val empty=Nil::Nil
> empty: List[object Nil] = List(List())
>
> scala> empty.head
> res11: object Nil = List()
>
> scala> val empty=List()::List()
> empty: List[List[Nothing]] = List(List())
>
> scala> empty.head
> res14: List[Nothing] = List()
>
> So is List[Nothing] and object Nil ..similar?
>
> thanks,
>
> SMS
>
>
> [Non-text portions of this message have been removed]
>
HI Mukund,
We Know that ,Type Nothing is subtype to every other type in scala.
meaning Like we know that Object is super type of all objects in java,
similarly Nothing a subtype of all types in Scala.At the bottom of the lattice.
Scala Library defines nil to be of type List[Nothing].
so Nil and Null both represents the same thing we can say that borth are similar.


Re: Re: List[Nothing] and object Nil

by Mukund :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Rajkmar,

Thank you...I even looked into Scala API and found that
Object Nil extends List[Nothing]\

thanks,

SMS

On Fri, Jul 10, 2009 at 2:13 PM, rajkumargoel_786 <
rajkumargoel_786@...> wrote:

>
>
> --- In twincling@... <twincling%40yahoogroups.com>, Mukund
> Deshpande <mukund.twincling@...> wrote:
> >
> > Hi all,
> >
> > scala> val empty=Nil::Nil
> > empty: List[object Nil] = List(List())
> >
> > scala> empty.head
> > res11: object Nil = List()
> >
> > scala> val empty=List()::List()
> > empty: List[List[Nothing]] = List(List())
> >
> > scala> empty.head
> > res14: List[Nothing] = List()
> >
> > So is List[Nothing] and object Nil ..similar?
> >
> > thanks,
> >
> > SMS
> >
> >
> > [Non-text portions of this message have been removed]
> >
> HI Mukund,
> We Know that ,Type Nothing is subtype to every other type in scala.
> meaning Like we know that Object is super type of all objects in java,
> similarly Nothing a subtype of all types in Scala.At the bottom of the
> lattice.
> Scala Library defines nil to be of type List[Nothing].
> so Nil and Null both represents the same thing we can say that borth are
> similar.
>
>  
>


[Non-text portions of this message have been removed]


Re: Re: List[Nothing] and object Nil

by SANAULLAH-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

2009/7/10 Mukund Deshpande <mukund.twincling@...>:

>
>
> Hi Rajkmar,
>
> Thank you...I even looked into Scala API and found that
> Object Nil extends List[Nothing]\
>
> thanks,
>
> SMS
>
> On Fri, Jul 10, 2009 at 2:13 PM, rajkumargoel_786 <
> rajkumargoel_786@...> wrote:
>
>>
>>
>> --- In twincling@... <twincling%40yahoogroups.com>, Mukund
>
>> Deshpande <mukund.twincling@...> wrote:
>> >
>> > Hi all,
>> >
>> > scala> val empty=Nil::Nil
>> > empty: List[object Nil] = List(List())
>> >
>> > scala> empty.head
>> > res11: object Nil = List()
>> >
>> > scala> val empty=List()::List()
>> > empty: List[List[Nothing]] = List(List())
>> >
>> > scala> empty.head
>> > res14: List[Nothing] = List()
>> >
>> > So is List[Nothing] and object Nil ..similar?
>> >

Read a well explained article about Null, Nothing, Nil, Unit in Scala-
http://oldfashionedsoftware.com/2008/08/20/a-post-about-nothing/

Regards,

Mohamed Sanaulla
http://twitter.com/letmeknowupdate

Re: Re: List[Nothing] and object Nil

by rajkumar goel :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

HI Sana,
That was good.Thanks

On Sun, Jul 12, 2009 at 11:02 PM, SANAULLAH <sanaulla123@...> wrote:

>
>
> 2009/7/10 Mukund Deshpande <mukund.twincling@...<mukund.twincling%40gmail.com>
> >:
> >
> >
> > Hi Rajkmar,
> >
> > Thank you...I even looked into Scala API and found that
> > Object Nil extends List[Nothing]\
> >
> > thanks,
> >
> > SMS
> >
> > On Fri, Jul 10, 2009 at 2:13 PM, rajkumargoel_786 <
> > rajkumargoel_786@... <rajkumargoel_786%40yahoo.co.in>> wrote:
> >
> >>
> >>
> >> --- In twincling@... <twincling%40yahoogroups.com><twincling%
> 40yahoogroups.com>, Mukund
> >
> >> Deshpande <mukund.twincling@...> wrote:
> >> >
> >> > Hi all,
> >> >
> >> > scala> val empty=Nil::Nil
> >> > empty: List[object Nil] = List(List())
> >> >
> >> > scala> empty.head
> >> > res11: object Nil = List()
> >> >
> >> > scala> val empty=List()::List()
> >> > empty: List[List[Nothing]] = List(List())
> >> >
> >> > scala> empty.head
> >> > res14: List[Nothing] = List()
> >> >
> >> > So is List[Nothing] and object Nil ..similar?
> >> >
>
> Read a well explained article about Null, Nothing, Nil, Unit in Scala-
> http://oldfashionedsoftware.com/2008/08/20/a-post-about-nothing/
>
> Regards,
>
> Mohamed Sanaulla
> http://twitter.com/letmeknowupdate
>  
>



--
Regards,
Rajkumar Goel
www.twitter.com/rajkumargoel
www.latestfever.blogspot.com


[Non-text portions of this message have been removed]