[Newbies] String construction and replacement

Randal L. Schwartz merlyn at stonehenge.com
Sun Feb 1 21:53:43 UTC 2009


>>>>> "David" == David Mitchell <david.mitchell at gmail.com> writes:

David> | characters string |
David> characters := {$H.$I.Character cr. $T.$H.$E.$R.$E}.
David> string := String streamContents: [:writeStream | characters do: [:c |
David> writeStream nextPut: c]].

chars := {$H.$I.Character cr. $T.$H.$E.$R.$E}.
string := chars as: String.

Far simpler.  Look at #as:... it's a pretty good "force this into that"
call.

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn at stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
See http://methodsandmessages.vox.com/ for Smalltalk and Seaside discussion


More information about the Beginners mailing list