[VW 7.5] [Bug] MacFilename class>>logicalComponents should answer an OrderedCollection (Liskov's substitution principle?)

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[VW 7.5] [Bug] MacFilename class>>logicalComponents should answer an OrderedCollection (Liskov's substitution principle?)

Stew MacLean

It’s a bit pedantic (and obsolete?), but nevertheless bit me in the…

 

logicalComponents: aNameString

 

            | list first prefix |

            list := self components: aNameString.

            list size = 0 ifTrue: [^#()].

            first := list first.

            prefix := first = ':'

                        ifTrue: [#()]

                        ifFalse: [('$(*):' match: first)

                                    ifTrue: [Array with: (first copyWithout: $:)]

                                    ifFalse: [Array with: first]].

            ^prefix, ((2 to: list size) collect: [:i |

                                    (list at: i) = ':'

                                                ifTrue: [list at: i]

                                                ifFalse: [(list at: i) copyWithout: $:]])

 

should answer an OrderedCollection to conform to the other implementation and that of components: