Search code examples
smalltalksqueak

Append two strings


I'm trying to append two string to each other in squeak(version 4.5) and there is no success. For example(what i wish to do):

str1:='hello '.
str2:='world'.
appendStr:= str1 + str2.

There is a way to do that in squeak? (note: the + operator is not necessary- just example)

Thanks a lot, Nisan.


Solution

  • It is possible, you need to use the #, (comma) message like this:

    | string1 string2 complete |
    string1 := 'Hello '.
    string2 := 'World!'.
    complete := string1, string2.
    

    Note that in Smalltalk, comma is no syntax but just another message.