[squeak-dev] The Inbox: Collections-cmm.1022.mcz

Thiede, Christoph Christoph.Thiede at student.hpi.uni-potsdam.de
Mon Nov 21 00:11:28 UTC 2022


> Interestingly, the in-image Method Finder doesn't find either one.

Simulation Method Finder does. :-)

Best,
Christoph

________________________________
Von: Squeak-dev <squeak-dev-bounces at lists.squeakfoundation.org> im Auftrag von Chris Muller <asqueaker at gmail.com>
Gesendet: Montag, 21. November 2022, 00:00
An: The general-purpose Squeak developers list <squeak-dev at lists.squeakfoundation.org>
Betreff: Re: [squeak-dev] The Inbox: Collections-cmm.1022.mcz

You're all 100% right.  I had forgotten about #splitBy:, but changing subStrings: certainly didn't feel right.  Interestingly, the in-image Method Finder doesn't find either one.  Thank you, community!  :)

I moved this to Treated.

 - Chris

On Sat, Nov 19, 2022 at 6:23 AM Thiede, Christoph <Christoph.Thiede at student.hpi.uni-potsdam.de<mailto:Christoph.Thiede at student.hpi.uni-potsdam.de>> wrote:

Hm ... don't we have #splitBy: for this? This seems like a possibly dangerous breaking change to me. No strong opinion, though. :-)


Best,

Christoph

________________________________
Von: Squeak-dev <squeak-dev-bounces at lists.squeakfoundation.org<mailto:squeak-dev-bounces at lists.squeakfoundation.org>> im Auftrag von Chris Muller <asqueaker at gmail.com<mailto:asqueaker at gmail.com>>
Gesendet: Samstag, 19. November 2022 06:24:43
An: squeak-dev at lists.squeakfoundation.org<mailto:squeak-dev at lists.squeakfoundation.org>
Betreff: Re: [squeak-dev] The Inbox: Collections-cmm.1022.mcz

I don't know why subStrings: should behave differently for empty fields as non-empty.

Before this change, empty fields are ignored:

    'a:b::d' subStrings: ':'  ==> " #('a' 'b' 'd') "
    '::::' subStrings: ':' ==> #()

after this change, empty fields are honored:

    'a:b::d' subStrings: ':'  ==> " #('a' 'b' '' 'd') "
    '::::' subStrings: ':' ==>  #('' '' '' '')

Thoughts?

 - Chris

On Fri, Nov 18, 2022 at 11:14 PM <commits at source.squeak.org<mailto:commits at source.squeak.org>> wrote:
Chris Muller uploaded a new version of Collections to project The Inbox:
http://source.squeak.org/inbox/Collections-cmm.1022.mcz

==================== Summary ====================

Name: Collections-cmm.1022
Author: cmm
Time: 18 November 2022, 11:14:01.223447 pm
UUID: 9a05d251-4f02-43de-94e8-0f077ec51680
Ancestors: Collections-nice.1021

Allow empty fields when using #subStrings:.

=============== Diff against Collections-nice.1021 ===============

Item was changed:
  ----- Method: String>>subStrings: (in category 'converting') -----
  subStrings: separators
        "Answer an array containing the substrings in the receiver separated
        by the elements of separators."
        | char result sourceStream subString |
-       #Collectn.
-       "Changed 2000/04/08 For ANSI <readableString> protocol."
        (separators isString or:[separators allSatisfy: [:element | element isCharacter]]) ifFalse:
                [^ self error: 'separators must be Characters.'].
        sourceStream := ReadStream on: self.
        result := OrderedCollection new.
        subString := String new.
        [sourceStream atEnd]
                whileFalse:
                        [char := sourceStream next.
                        (separators includes: char)
+                               ifTrue: [result add: subString copy.
+                                                       subString := String new]
-                               ifTrue: [subString notEmpty
-                                               ifTrue:
-                                                       [result add: subString copy.
-                                                       subString := String new]]
                                ifFalse: [subString := subString , (String with: char)]].
        subString notEmpty ifTrue: [result add: subString copy].
        ^ result asArray!




-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20221121/cf5e9909/attachment.html>


More information about the Squeak-dev mailing list