- About Scala
- Documentation
- Code Examples
- Software
- Scala Developers
Why no mutable "List"?
Sat, 2010-03-20, 02:19
Scala has both a mutable and an immutable "Map", but it has only an immutable "List." If you want a mutable "List," you need a "ListBuffer." Am I missing something, or is that a slight inconsistency?
Russ P.
Russ P.
Sat, 2010-03-20, 07:27
#2
Re: Why no mutable "List"?
More to the point, Seq, Map and Set are abstract classes. List is an implementation of a Seq, as is ListBuffer.
On Fri, Mar 19, 2010 at 10:52 PM, Randall R Schulz <rschulz@sonic.net> wrote:
--
Daniel C. Sobral
I travel to the future all the time.
On Fri, Mar 19, 2010 at 10:52 PM, Randall R Schulz <rschulz@sonic.net> wrote:
On Friday March 19 2010, Russ Paielli wrote:
> Scala has both a mutable and an immutable "Map", ...
And Set.
> ... but it has only an immutable "List."
> If you want a mutable "List," you need a "ListBuffer." ...
ListBuffer is the mutable List.
List is special thing. It is in its very essence immutable.
(Pay no attention to Common Lisp and it's heinous cons cell mutators.)
> Russ P.
Randall Schulz
--
Daniel C. Sobral
I travel to the future all the time.
Sat, 2010-03-20, 18:57
#3
Re: Why no mutable "List"?
On Fri, Mar 19, 2010 at 11:21 PM, Daniel Sobral <dcsobral@gmail.com> wrote:
I think List is an abstract class too:
--
http://RussP.us
More to the point, Seq, Map and Set are abstract classes. List is an implementation of a Seq, as is ListBuffer.
I think List is an abstract class too:
On Fri, Mar 19, 2010 at 10:52 PM, Randall R Schulz <rschulz@sonic.net> wrote:
On Friday March 19 2010, Russ Paielli wrote:
> Scala has both a mutable and an immutable "Map", ...
And Set.
> ... but it has only an immutable "List."
> If you want a mutable "List," you need a "ListBuffer." ...
ListBuffer is the mutable List.
List is special thing. It is in its very essence immutable.
(Pay no attention to Common Lisp and it's heinous cons cell mutators.)
> Russ P.
Randall Schulz
--
Daniel C. Sobral
I travel to the future all the time.
--
http://RussP.us
Mon, 2010-03-22, 01:47
#4
Re: Why no mutable "List"?
Ah, well, true enough. But that's a minor construction detail -- as one can see by the "sealed". That means the only classes extending List are defined in the same file. List is effectively a specific implementation of an immutable Seq, which happens to be defined through the concrete classes Cons and Nil.
On Sat, Mar 20, 2010 at 2:53 PM, Russ Paielli <russ.paielli@gmail.com> wrote:
--
Daniel C. Sobral
I travel to the future all the time.
On Sat, Mar 20, 2010 at 2:53 PM, Russ Paielli <russ.paielli@gmail.com> wrote:
On Fri, Mar 19, 2010 at 11:21 PM, Daniel Sobral <dcsobral@gmail.com> wrote:
More to the point, Seq, Map and Set are abstract classes. List is an implementation of a Seq, as is ListBuffer.
I think List is an abstract class too:
On Fri, Mar 19, 2010 at 10:52 PM, Randall R Schulz <rschulz@sonic.net> wrote:
On Friday March 19 2010, Russ Paielli wrote:
> Scala has both a mutable and an immutable "Map", ...
And Set.
> ... but it has only an immutable "List."
> If you want a mutable "List," you need a "ListBuffer." ...
ListBuffer is the mutable List.
List is special thing. It is in its very essence immutable.
(Pay no attention to Common Lisp and it's heinous cons cell mutators.)
> Russ P.
Randall Schulz
--
Daniel C. Sobral
I travel to the future all the time.
--
http://RussP.us
--
Daniel C. Sobral
I travel to the future all the time.
Mon, 2010-03-22, 02:37
#5
Hardest bug so far (newbie)
def buf = new StringBuilder(64);
....
buf.append(someString)
...
System.out.println(buf.toString)
Finding this in 100 lines of code took a while
Richard
Mon, 2010-03-22, 02:47
#6
Re: Hardest bug so far (newbie)
I have had def sneak up on me. Finding it in a dozen lines is difficult as well...
On Sun, Mar 21, 2010 at 10:27 PM, richard emberson <richard.emberson@gmail.com> wrote:
On Sun, Mar 21, 2010 at 10:27 PM, richard emberson <richard.emberson@gmail.com> wrote:
def buf = new StringBuilder(64);
....
buf.append(someString)
...
System.out.println(buf.toString)
Finding this in 100 lines of code took a while
Richard
On Friday March 19 2010, Russ Paielli wrote:
> Scala has both a mutable and an immutable "Map", ...
And Set.
> ... but it has only an immutable "List."
> If you want a mutable "List," you need a "ListBuffer." ...
ListBuffer is the mutable List.
List is special thing. It is in its very essence immutable.
(Pay no attention to Common Lisp and it's heinous cons cell mutators.)
> Russ P.
Randall Schulz