[squeak-dev] How to rewrite a license restricted method?

Igor Stasenko siguctua at gmail.com
Mon Feb 9 13:45:14 UTC 2009


2009/2/9 Bert Freudenberg <bert at freudenbergs.de>:
>
> On 08.02.2009, at 20:26, Ken Causey wrote:
>
>> SequenceableCollection>>asStringWithCr
>>
>> 1) SqueakV1.sources:
>>
>> asStringWithCr
>>        "Convert to a string with returns between items.  Elements are
>> usually
>> strings.
>>         Useful for labels for PopUpMenus."
>>        | labelStream |
>>        labelStream _ WriteStream on: (String new: 200).
>>        self do: [:each |
>>                (each isKindOf: String)
>>                        ifTrue: [labelStream nextPutAll: each; cr]
>>                        ifFalse: [each printOn: labelStream; cr]].
>>        self size > 0 ifTrue: [labelStream skip: -1].
>>        ^ labelStream contents!
>

How about this one:

 asStringWithCr
        "Convert to a string with returns between items.  Elements are
usually strings.
         Useful for labels for PopUpMenus."
        ^ String streamContents: [:str |
            self do: [:each | str nextPutAll: each asString ]
separatedBy: [ str cr ]
        ]

Btw, i was surprised to see in String>>printOn: something else than
'stream nextPutAll: self' , otherwise we could simply put
'each printOn: str' in the method above.

-- 
Best regards,
Igor Stasenko AKA sig.



More information about the Squeak-dev mailing list