--- Begin Message ---
Op 30-4-2020 om 10:31 schreef Ben Coman:
collection := '8569 2478 0383 3437'.
(collection reverse selectWithIndex: [:item :index | (index % 2 == 0) ifTrue: [item *2]] )  inspect


I see a error and the non-even numbers are nill now.

but after some figgeling this seems to work :

collection := '8569247803833437'asArray.
checkNumber := (collection reverse withIndexCollect: [:item :index | (index % 2 == 0) ifTrue: [item asInteger *2] ifFalse: [item asInteger]] ) sum inspect
^ checkNumber isDivisibleBy: 10





--- End Message ---

Reply via email to