[Newbies] [Q] How should one concatenate Strings?

David T. Lewis lewis at mail.msen.com
Sun May 7 05:55:08 UTC 2006


Hi Charles,

Try something like this:

   '<!', self class name, ';', name, '!>'

The comma character is actually is actually a message that is understood
by strings. The message is implemented in class Collection (in the
"copying" method category), and since strings are types of collections,
it works for strings also. 

Dave

On Sat, May 06, 2006 at 10:15:25PM -0700, Charles D Hixson wrote:
> Example:
> repr
>     "return a representation of THIS object"
>     |ic|
>     ic := self class.
>    ^(#('<!' (self class) ';'  name, '!>') asString).
> 
> Unfortunately, not only is this clunky, it returns a string array rather
> than a character string.  (Forgive any typos...I wanted a sensible
> example, but the reality was tested in the workspace.)
> 
> What I want is to just return a character string built from other
> character strings, some of which may be computer and other of which
> might be literal.
> 
> For example, what I might want returned could be the string
> '<!Android;Marvin!>'.
> 
> The only way I've been able to figure out how to do this is to create a
> sufficiently long string (after calculating the length of each piece)
> and then to use at:put:


More information about the Beginners mailing list