Lets start monday morning with an intuitive error message:
Dictionary new at: 1 put: 1; keysAndValuesDo: [:each | ].
"Error: This block accepts 1 argument, but was called with 2"
Hmm, I don't see the problem.
The block [ :each | ... ] accepts only one argument, named "each". But keysAndValuesDo: delivers two arguments. So the tight way would be
Dictionary new at: 1 put: 1; keysAndValuesDo: [:key :value | ... ].
Regards
mue
Lets start monday morning with an intuitive error message:
Dictionary new at: 1 put: 1; keysAndValuesDo: [:each | ].
"Error: This block accepts 1 argument, but was called with 2"
So, it should read;
"Error: This block accepts 2 arguments, but was called with 1"
;-)
Frank Mueller skrev:
Hmm, I don't see the problem.
The block [ :each | ... ] accepts only one argument, named "each". But keysAndValuesDo: delivers two arguments. So the tight way would be
Dictionary new at: 1 put: 1; keysAndValuesDo: [:key :value | ... ].
Regards
mue
Lets start monday morning with an intuitive error message:
Dictionary new at: 1 put: 1; keysAndValuesDo: [:each | ].
"Error: This block accepts 1 argument, but was called with 2"
Nope, the block accepts one.
[ :foo | ... ]
can only be called with one argument, not two or more. But
keysAndValuesDo: aBlock
calls it with two. The first is the key, the second is the value. It calls
aBlock value: key value: value.
The error is signaled by the block.
Regards
mue
So, it should read;
"Error: This block accepts 2 arguments, but was called with 1"
;-)
Frank Mueller skrev:
Hmm, I don't see the problem.
The block [ :each | ... ] accepts only one argument, named "each". But keysAndValuesDo: delivers two arguments. So the tight way would be
Dictionary new at: 1 put: 1; keysAndValuesDo: [:key :value | ... ].
Regards
mue
Lets start monday morning with an intuitive error message:
Dictionary new at: 1 put: 1; keysAndValuesDo: [:each | ].
"Error: This block accepts 1 argument, but was called with 2"
I understand this now. But I dont think the error message is *helping* me to understand it.
CPS
Nope, the block accepts one.
[ :foo | ... ]
can only be called with one argument, not two or more. But
keysAndValuesDo: aBlock
calls it with two. The first is the key, the second is the value. It calls
aBlock value: key value: value.
The error is signaled by the block.
Regards
mue
So, it should read;
"Error: This block accepts 2 arguments, but was called with 1"
;-)
Frank Mueller skrev:
Hmm, I don't see the problem.
The block [ :each | ... ] accepts only one argument, named "each". But keysAndValuesDo: delivers two arguments. So the tight way would be
Dictionary new at: 1 put: 1; keysAndValuesDo: [:key :value | ... ].
Regards
mue
Lets start monday morning with an intuitive error message:
Dictionary new at: 1 put: 1; keysAndValuesDo: [:each | ].
"Error: This block accepts 1 argument, but was called with 2"
squeak-dev@lists.squeakfoundation.org