I am trying to create a keyword message style method, but I can't figure out how to access the Receiver from inside the method. I am sure this is simple, however I can't find the answer anywhere. What I am trying to implement is redundant, but I would still like to know how it works.
subst: i1 by: i2
^ self copyReplaceAll: i1 with: i2.
It would be called in the workspace as follows:
string1 := 'Lemon'.
string2 := 'm'.
string3 := 'ss'.
string1 subst: string2 by: string3.
Error msg: "MessageNotUnderstood: ByteString>>subst:by:"
All the method should do is replace every occurance of "m" in "Lemon" with "ss" to create "Lesson" (which copyReplaceAll already does). I can't figure out how to get string1 into the method. Any help would be greatly appreciated,
Thanks in advance!
self
is the current object (i.e. the receiver).
Please read (or at least skim) a tutorial to get the basics.
"MessageNotUnderstood: ByteString>>subst:by:"
This error means that you have not defined the message on ByteString. Either you have failed to actually define it anywhere, or you have defined it on the wrong class.