I ran into the following problem (related to FamixModelExtractionTest even if it's more general)
(#((1) (3) () ()) flatCollect: [ :each ]) returns #(1 3 nil nil)
when one expects #(1 3)
flatCollect: is defined in Colllection, I dont want to override it if possible. Collection>>flatCollect: aBlock | stream | self isEmpty ifTrue: [ ^ self copy ]. stream := (self species new: self size) nsWriteStream. self do: [ :each | stream nextPutAll: (aBlock value: each) ]. ^ stream contents
Can someone find an elegant solution which would "shrink" the resulting array to its non-nil content?
-- Simon
That is strange. In VW it works. I did not look at the Pharo implementation, though so I do not know what is different.
Cheers, Doru
On 30 Mar 2009, at 18:03, Simon Denier wrote:
I ran into the following problem (related to FamixModelExtractionTest even if it's more general)
(#((1) (3) () ()) flatCollect: [ :each ]) returns #(1 3 nil nil)
when one expects #(1 3)
flatCollect: is defined in Colllection, I dont want to override it if possible. Collection>>flatCollect: aBlock | stream | self isEmpty ifTrue: [ ^ self copy ]. stream := (self species new: self size) nsWriteStream. self do: [ :each | stream nextPutAll: (aBlock value: each) ]. ^ stream contents
Can someone find an elegant solution which would "shrink" the resulting array to its non-nil content?
-- Simon
Moose-dev mailing list Moose-dev@iam.unibe.ch https://www.iam.unibe.ch/mailman/listinfo/moose-dev
-- www.tudorgirba.com
"Every successful trip needs a suitable vehicle."
I am having a look at it right now
Alexandre
On 1 Apr 2009, at 10:50, Tudor Girba wrote:
That is strange. In VW it works. I did not look at the Pharo implementation, though so I do not know what is different.
Cheers, Doru
On 30 Mar 2009, at 18:03, Simon Denier wrote:
I ran into the following problem (related to FamixModelExtractionTest even if it's more general)
(#((1) (3) () ()) flatCollect: [ :each ]) returns #(1 3 nil nil)
when one expects #(1 3)
flatCollect: is defined in Colllection, I dont want to override it if possible. Collection>>flatCollect: aBlock | stream | self isEmpty ifTrue: [ ^ self copy ]. stream := (self species new: self size) nsWriteStream. self do: [ :each | stream nextPutAll: (aBlock value: each) ]. ^ stream contents
Can someone find an elegant solution which would "shrink" the resulting array to its non-nil content?
-- Simon
Moose-dev mailing list Moose-dev@iam.unibe.ch https://www.iam.unibe.ch/mailman/listinfo/moose-dev
-- www.tudorgirba.com
"Every successful trip needs a suitable vehicle."
Moose-dev mailing list Moose-dev@iam.unibe.ch https://www.iam.unibe.ch/mailman/listinfo/moose-dev
Hi Simon,
As you and Doru pointed out, in VW you get #(1 3) and in Pharo #(1 3 nil nil). I am not sure which result is the less surprising. The result of '#((1) (3) () ()) collect: [:each ]' contains nil as well.
An elegant solution to remove nil value, is simply to use 'reject: #isNil' (#((1) (3) () ()) flatCollect: [ :each ]) reject: #isNil
Cheers, Alexandre
On 30 Mar 2009, at 18:03, Simon Denier wrote:
I ran into the following problem (related to FamixModelExtractionTest even if it's more general)
(#((1) (3) () ()) flatCollect: [ :each ]) returns #(1 3 nil nil)
when one expects #(1 3)
flatCollect: is defined in Colllection, I dont want to override it if possible. Collection>>flatCollect: aBlock | stream | self isEmpty ifTrue: [ ^ self copy ]. stream := (self species new: self size) nsWriteStream. self do: [ :each | stream nextPutAll: (aBlock value: each) ]. ^ stream contents
Can someone find an elegant solution which would "shrink" the resulting array to its non-nil content?
-- Simon
Moose-dev mailing list Moose-dev@iam.unibe.ch https://www.iam.unibe.ch/mailman/listinfo/moose-dev