Simple String Question.

Richard A. O'Keefe ok at cs.otago.ac.nz
Thu May 16 00:51:47 UTC 2002


Jimmie Houchin <jhouchin at texoma.net> wrote:
	My books are at home and I am having difficulty finding how to
	put two strings together.
	
The Squeak Way to answer questions like this is
 1. Open a Method Finder.
 2. In the top left pane, type
	'foo'. 'bar'. 'foobar'
    (the receiver, any arguments, and then the result)
 3. Accept (Cmd-s, or Return these days)
In the middle left pane, you will then see
        'foo' , 'bar' --> 'foobar'
and this tells you that the string concatenation selector is #,

If you then select the comma and do "implementors of it" (Cmd-m)
you'll get an "Implementors of ," window from which you'll discover
that it's not actually a String method, it's a SequenceableCollection method.

	In Python and I think other languages (I believe) I can do in Smalltalk 
	form:
	
	a := 'StringOne'
	b := 'StringTwo'
	c := a + b
	
Disgusting, isn't it?  + should always mean "add two numbers", or
at any rate "perform such-and-such a commutative ring operation".
In APL concatenation was ",", in ML it's "<>", in Haskell it's "++",
in Ada it's "&", you pays your money and you takes someone else's choice.

Another Smalltalk way to look for this would be to type
    concatenate
in some window, select that word, then choose "method source with it".
That takes rather a long time, and there's always the possibility that
the comment says "append" or "paste" or "glue", but when you're desperate...
If you try this in 3.0.1, "SequenceableCOllection , {copying}" is the 6th
item in the list of results.

(By the way, why do the graphics methods speak of CONCATENATING
transformations when they mean COMPOSING them?  Very confusing.)



More information about the Squeak-dev mailing list