Intended behaviour of String>>collect: and similar

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

Intended behaviour of String>>collect: and similar

Chris Uppal-3
Hi,

What is the intended interpretation of expressions like:

    'Hello' collect: [:each | each codePoint]

or:

    'Hello' associations

In the current implementation, both expressions produce errors -- can't hold
SmallInteger's (sic).

I don't much care whether such expressions are supposed to produce errors or
not, but I'm working on a String-like class and would like to emulate the
/intended/ behaviour as far as possible, rather than the actual behaviour
(which may be buggy).  Especially as the actual behaviour is rather awkward to
emulate ;-)

    -- chris


Reply | Threaded
Open this post in threaded view
|

Re: Intended behaviour of String>>collect: and similar

Fernando Rodriguez
On Thu, 21 Apr 2005 11:11:39 +0100, "Chris Uppal"
<[hidden email]> wrote:


>I don't much care whether such expressions are supposed to produce errors or
>not, but I'm working on a String-like class and would like to emulate the
>/intended/ behaviour as far as possible, rather than the actual behaviour
>(which may be buggy).  Especially as the actual behaviour is rather awkward to
>emulate ;-)


I guess the only way would be to check the ANSI standard, wherever it
is available. I tried it on Squeak, and got a similar behavior.

The behavior that would make sense to me woul be the equivalent to:

'aaa' asOrderedCollection collect: [:char| char codePoint]
'assf' asOrderedCollection associations

Or asArray.