[squeak-dev] EncodedCharSet class>charsetAt:

tim Rowledge tim at rowledge.org
Tue Oct 1 21:38:42 UTC 2013


On 01-10-2013, at 2:19 PM, Nicolas Cellier <nicolas.cellier.aka.nice at gmail.com> wrote:

> (1 to: 30) collect: [:i | EncodedCharSet charsetAt: i]

Well that is interesting. The code uses at:ifAbsent:, clearly intending to prevent a nil result - and as I mentioned all but two senders rely on a 'proper' answer. Oh, here we are - SequenceableCollection>at:ifAbsent: *only* treats outside the 1..size range as absent, not a nil. I'm thinking the original code was predicated on a Dictionary and then the collection was changed to an Array.

So I'd suggest 
charsetAt: encoding

	^ (EncodedCharSets at: encoding + 1) ifNil: [EncodedCharSets at: 1].
… assuming we prefer 

(1 to: 30) collect: [:i | EncodedCharSet charsetAt: i]  
--> {JISX0208 . GB2312 . KSX1001 . JISX0208 . JapaneseEnvironment . SimplifiedChineseEnvironment . KoreanEnvironment . GB2312 . Unicode . Unicode . Unicode . KSX1001 . Unicode . Unicode . Unicode . Unicode . Unicode . Unicode . Unicode . Unicode . Unicode . Unicode . Unicode . Unicode . Unicode . Unicode . Unicode . Unicode . Unicode . Unicode}

At least it isn't {Developers. Developers. Developers. Developers. Developers. Developers. Developers. } ;-)

tim
--
tim Rowledge; tim at rowledge.org; http://www.rowledge.org/tim
Implementation is the sincerest form of flattery.




More information about the Squeak-dev mailing list