I'm trying to go though a array and add characters from that array to another object. The problem is I keep getting a error "Instances of character are not indexable". However when I run tag := tag,char outside of the do block then it works.
|data startTag tag|.
data := '123456778'
startTag := false.
tag := ''.
data asArray do: [:char |
tag := tag,char]
The
,
is defined asso that tries to operate on your single character as if it were a collection. That explains the error.
For larger collections you do not want to build up using
,
because of the copy that happens each time. Therefore use the streaming protocol:Also take a look at
Collection>>do:separatedBy:
to add separators between your data.[edit] Ah, ok, that's something like