How do I define my own operators in the Io programming language?

Posted by klep on Stack Overflow See other posts from Stack Overflow or by klep
Published on 2010-05-28T04:19:16Z Indexed on 2010/05/28 4:21 UTC
Read the original article Hit count: 155

Filed under:

I'm trying to define my own operator in Io, and I'm having a hard time. I have an object:

MyObject := Object clone do(
  lst := list()
  !! := method(n, lst at(n))
)

But when I call it, like this:

x := MyObject clone do(lst appendSeq(list(1, 2, 3)))
x !! 2

But I get an exception that argument 0 to at must not be nil. How can I fix?

© Stack Overflow or respective owner

Related posts about object-oriented