Yes, the concatenation method (it is, #,) works only with collections(*). There is no automatic casting of objects to a string representation. In the long run you'll love that.
And since String "is a" Collection, you can't send #, to other object, and neither pass an argument that is not a collection. Hence the need of the "conversion"(**) to a String. (*) In some particular cases the #, method is implemented in non collection classes for convenience. (**) There is no conversion taking place, your object is returning another one, instance of String, that is supposed to represent it as a whole or some aspect of it. You might create the String every time the message is received or if it is its name, you just return it. ps: I don't know how this relates to the Morphic subject :) Esteban A. Maringolo 2013/1/2 J. P. L. Martín <[email protected]>: > Done, I've just append asString on the collect: block. > > :D > > > On Wed, Jan 2, 2013 at 11:18 AM, Esteban A. Maringolo <[email protected]> > wrote: >> >> 2013/1/2 J. P. L. Martín <[email protected]>: >> > Another question, when I try this: >> > >> > Prestamo database collect: [:x | x id,' ',x idMaterial] >> > >> > I get Receiver of "," nil. How do I solve it? >> >> You probably have one or more elements in the collection returned by >> "Prestamo database" whose id's are nil. >> Then you're sending #, to a nil element. >> >> I would ensure all elements have an ID, or better than that I would >> delegate the printing responsibility to the element itself. >> It is: >> Prestamo database collect: [:x | x printIdAndMaterial] >> >> This way the testing of a nil id is done by the receiver. >> >> Regards, >> >> Esteban. >> >
