Question

I wrote following method to get all slot names of object (without slots of Lobby and highter):

Object allSlotNames := method(
    result := list()
    object := self
    while(object != Lobby,
        result appendSeq(object slotNames)
        object := object proto
    )
    result
)

But when I run it i get an error:

Io> 123 allSlotNames

Exception: Number does not respond to 'object'
---------
Number object                        Command Line 1
Number allSlotNames                  Command Line 1

Why?

Was it helpful?

Solution

Your code works as posted I ran it as a file. I was able to get it to work in the REPL by adding some explicit semicolons:

Object allSlotNames := method(
    result := list();
    object := self;
    while(object != Lobby,
        result appendSeq(object slotNames);
        object := object proto;
    );
    result;
)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top