I am trying to write a method which returns a new value. Following code is modified from here:
| stripChars | stripChars := [ :string :chars | str := string reject: [ :c | chars includes: c ]. str displayNl. "THIS WORKS." ^ str "THIS DOES NOT WORK." ]. newstr := stripChars value: 'She was a soul stripper. She took my heart!' value: 'aei'. newstr displayNl.
Although above function creates new string and displays it, there is error in returning or receiving returned new string:
$ gst make_fn_ques.st Sh ws soul strppr. Sh took my hrt! Object: 'Sh ws soul strppr. Sh took my hrt!' error: return from a dead method context SystemExceptions.BadReturn(Exception)>>signal (ExcHandling.st:254) SystemExceptions.BadReturn class(Exception class)>>signal (ExcHandling.st:151) String(Object)>>badReturnError (Object.st:1389) UndefinedObject>>executeStatements (make_fn_ques.st:10) nil
Where is the problem and how can this be solved? Thanks for your help.