Reputation: 1746
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?
Upvotes: 0
Views: 119
Reputation: 10841
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;
)
Upvotes: 1