annoyed (7) [Avatar] Offline
#1
Pasting this code into the REPL:

scala> abstract class AList {
| def head:Int
| def tail:AList
| def isEmpty:Boolean
| def :smilien:Int):AList = SimpleList(n, this)
| }

results in this error:

<console>:13: error: type mismatch;
found : AList
required: SimpleList
def :smilien:Int):AList = SimpleList(n, this)
aslam.khan (50) [Avatar] Offline
#2
Re: Type Mismatch Error on p. 101
Hello again,

This is a behavior of the REPL that tries to interpret each statement, one at a time. Try this instead...

In the REPL, enter the command :paste (this allows you to type in multiple statements or just paste in a block of code)
Then hit CTRL-D when you are done, and the REPL will interpret all statements in one block.

Let me know if that worked for you. I will update the book to give this instruction too.
annoyed (7) [Avatar] Offline
#3
Re: Type Mismatch Error on p. 101
I'm still getting the same error:

scala> :paste
// Entering paste mode (ctrl-D to finish)

abstract class AList {
def head:Int
def tail:AList
def isEmpty:Boolean
def :smilien:Int):AList = SimpleList(n, this)
}

// Exiting paste mode, now interpreting.

<console>:13: error: type mismatch;
found : AList
required: SimpleList
def :smilien:Int):AList = SimpleList(n, this)
^
annoyed (7) [Avatar] Offline
#4
Re: Type Mismatch Error on p. 101
I got it to compile by copying all three blocks of code, however the compiler didn't like the quotation marks

scala> :paste
// Entering paste mode (ctrl-D to finish)

abstract class AList {
def head:Int
def tail:AList
def isEmpty:Boolean
def :smilien:Int):AList = SimpleList(n, this)
}
object Empty extends AList {
def head = throw new Exception("Empty List")
def tail = throw new Exception("Empty List")
def isEmpty = true
}
case class SimpleList(head:Int, tail:AList = Empty)
extends AList { def isEmpty = false }

// Exiting paste mode, now interpreting.

defined class AList
defined object Empty
defined class SimpleList
aslam.khan (50) [Avatar] Offline
#5
Re: Type Mismatch Error on p. 101
Yes, copying from the PDF will not translate the quotations correctly. For some of the lengthier examples, we will be putting together source code that will be downloadable.

I'm glad you got it to work.