<div dir="ltr"><div><div><div>In st-80, the keys did answer a Set and the values a Bag, with no obvious mapping between these two order-wise.<br></div>In Squeak, there were historically a fasterKeys that did answer an Array in order to avoid the overhead of testing uniqueness of keys and to avoid rehashing the keys...<br>Then we decided to simplify everything by answering an Array for both keys and values with the guaranty that (self at: (self keys at: i)) == (self values at: i) for any i from 1 to keys size...<br></div>But it&#39;s just a conveniency, it was not intended to be generalized...<br>Also, keep in mind that the order may change at any time with the mutations of the Dictionary...<br><br></div><div><br><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">2014-11-27 2:23 GMT+01:00 Florin Mateoc <span dir="ltr">&lt;<a href="mailto:florin.mateoc@gmail.com" target="_blank">florin.mateoc@gmail.com</a>&gt;</span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On 11/26/2014 7:14 PM, Levente Uzonyi wrote:<br>
&gt; Your example hides the problem of ordering - what Tobias is asking about - so here&#39;s another:<br>
&gt;<br>
&gt; (IdentitySet withAll: #(1 1.0)) collect: [ :each | each class ]<br>
&gt;<br>
&gt; If IdentitySet &gt;&gt; #collect: were returning an Array, then what would be the answer?<br>
&gt;<br>
&gt; { SmallInteger. Float } or { Float. SmallInteger } ?<br>
</span>snip<br>
&gt; Levente<br>
<br>
<br>
Then why does Dictionary&gt;&gt;keys return an Array? Where does the order come from in that example?<br>
Similarly, where does the order come from when you invoke collect:as: on a set with Array as an argument?<br>
The answer is quite simple: it is the iteration order. collect: is part of the _iteration_ protocol.<br>
<br>
I agree with Frank here, for me a more important aspect of collect: is preserving the _mapping_ between the original<br>
elements and the collected values.<br>
There is no obvious mapping if there are fewer collected values than elements.<br>
<span class="HOEnZb"><font color="#888888"><br>
Florin<br>
<br>
<br>
</font></span></blockquote></div><br></div>