This has not changed since Smalltalk-80. Running Smalltalk-80 and
looking in the browser, I see
Dictionary>>
do: aBlock
super do: [:assoc | aBlock value: assoc value].
'super' here is Set, a Dictionary being implemented as a Set of
Associations (which was always a bad idea).
Dictionary>>do: h
Wrong.
If you want to iterate of the associations of a dictionary, you need
#associationsDo:.
#do: passes the *values* to the block, *NOT* the associations.
On Wed, 24 Jan 2024 at 05:28, Joachim Tuchel wrote:
>
> AI knows little about Smalltalk ;-)
>
> You can use do: with each Association as a p
There are many books about Smalltalk. Stephane Ducasse has made many
of them available as FREE pdfs.
Of course Pharo by Example would be a good start. The latest edition
of Pharo by Example I have ready to hand is 8.0, 2020, where what you
want is chapter 13, Collections.
aCollection do: [:eleme
James is of course right.
do: iterates over the values, if you want the whole associations, you
use associationsDo:
At least I was right about keysAndValuesDo: ;-)
Joachim
myDict do: [:aValue | ]. “An alias for #valuesDo:”
James Foster
On Jan 23, 2024, at 8:27 AM, Joachim Tuchel
wro
In the dialects I am familiar with, James' answer is correct. Some dialects
implement #keysAndValuesDo: on sequenceable collections, in which case, the
keys are the indexes of the values.
On Tue, Jan 23, 2024, 12:05 sergio ruiz wrote:
> oh! this makes sense..
>
> let me try this.
>
> The trick i
oh! this makes sense..
let me try this.
The trick is, i have used the AI system from JetBrains (in my day job IDE)..
and it has figured out a bunch of smalltalk questions i had. Even questions
about the pharo ecosystem.
It hasn’t always been 100%, but it got me to look in the right place quick
So there we already have dialect differences …Am 23.01.2024 um 17:32 schrieb James Foster via Pharo-users :myDict associationsDo: [: anAssociation | ].myDict keysDo: [:aKey | ].myDict valuesDo: [:aValue | ].myDict do: [:aValue | ]. “An alias for #valuesDo:”James FosterOn Jan 23, 2024, at 8:27 AM,
myDict associationsDo: [: anAssociation | ].
myDict keysDo: [:aKey | ].
myDict valuesDo: [:aValue | ].
myDict do: [:aValue | ]. “An alias for #valuesDo:”
James Foster
> On Jan 23, 2024, at 8:27 AM, Joachim Tuchel wrote:
>
> AI knows little about Smalltalk ;-)
>
> You can use do: with each Asso
AI knows little about Smalltalk ;-)
You can use do: with each Association as a parameter or you can use
keysAndValuesDo:
myDic do: [:assoc| | key value| key := assoc key. value := assoc value. ...].
myDic keysAndValuesDo: [:key :value| ...]
Joachim
Am 23.01.24 um 17:24 schrieb sergio rui