The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

peterbwest (41) [Avatar] Offline
2.3 If a reader is following the text with an open scala interpreter, he will have to change the variable names given in the examples. For example, the val newList is defined differently twice within the space of a few lines. It would help if the reader is able simply to type these examples in as he goes.

2.4 The example, although accurate, is very confusing.

Message was edited by: peterbwest
nraychaudhuri (19) [Avatar] Offline
Re: 2.3 Working with Array and List and 2.4 Controlling flow...
Actually you can redefine val multiple times inside interpreter. For example the following example should work fine:

scala> val oldList = List(1, 2)
oldList: List[Int] = List(1, 2)

scala> val newList = 3 :: oldList
newList: List[Int] = List(3, 1, 2)

scala> val myList = "This" :: "is" :: "immutable" :: Nil
myList: List[java.lang.String] = List(This, is, immutable)

Let me know if this is still confusing.