Amitabha
Amitabha

Reputation: 1733

Io Language: Exception: Sequence does not respond to 'openForReading'

I'm study "seven languages in seven weeks".

On Io charpter, I run following example failed with following exception.

#phonebook.io
OperatorTable addAssignOperator(":", "atPutNumber")
curlyBrackets := method(
  r := Map clone
  call message arguments foreach(arg,
       r doMessage(arg)
       )
  r
)

Map atPutNumber := method(
  self atPut(
       call evalArgAt(0) asMutable removePrefix("\"") removeSuffix("\""),
       call evalArgAt(1))
)

s := File with("phonebook.txt" openForReading contents)

phoneNumbers := doString(s)
phoneNumbers keys println
phoneNumbers values println

phonebook.txt

{
        "Bob  Smith" : "12345",
        "Mary Walsh" : "5678"
}

Exception message:

Exception: Sequence does not respond to 'openForReading' ---------
Sequence openForReading phonebook.io 16 File with
phonebook.io 16 CLI doFile Z_CLI.io 140
CLI run IoState_runCLI() 1

phonebook.io and phonebook.txt in same folder.

Upvotes: 0

Views: 405

Answers (1)

Amitabha
Amitabha

Reputation: 1733

Compare code line by line, following line

s := File with("phonebook.txt" openForReading contents)

should correct as:

s := File with("phonebook.txt") openForReading contents

At last works as expected:

$> io phonebook.io
list(Mary Walsh, Bob Smith)
list(5678, 12345)

Upvotes: 1

Related Questions