2010/10/23 Luc Fabresse <[email protected]>:
> Hi Simon,
> If I understand well, you should use a dot to separate the two expressions
> in the block.
> |test isFact|
>
> test := Array new:5.
> isFact := False.
> test doWithIndex:[ :each :i | ((each isNil) & (isFact = False))
> ifTrue:[
> test at:i put:'plain'.
> isFact := True
> ]
> ].
>
> #Luc
>
Also using classes False and True rather than their instances false
and true is questionnable.
|test isFact|
test := Array new:5.
isFact := false.
test doWithIndex:[ :each :i | ((each isNil) & (isFact not))
ifTrue:[
test at:i put:'plain'.
isFact := true
]
].
This code find the first nil and replace it with 'plain', so it could
be as well:
| test isFact firstNilIndex |
test := Array new: 5.
firstNilIndex := test findFirst: [:each | each isNil].
isFact := firstNilIndex > 0.
isFact ifTrue: [test at: firstNilIndex put: 'plain'].
Nicolas
>
> 2010/10/23 Simon De Baets <[email protected]>
>>
>> Hello,
>>
>> I use Pharo 1.1 . I want to add a new element in an array that have a
>> part of nil element. I want to add this new element on the first nil case. I
>> produce this code
>>
>> |test isFact|
>>
>> test := Array new:5.
>> isFact := False.
>> test doWithIndex:[ :each :i | ((each isNil) & (isFact = False))
>> ifTrue:[
>> test at:i put:'plain'; isFact := True
>> ]
>> ].
>> test.
>>
>> But it doesn't function because they are two instruction in the ifTrue
>> bolck. So my question is : "How can i put two instructions in an ifTrue
>> block?"
>>
>> Thanks,
>>
>> --
>> Simon De Baets,
>> Etudiant en MA1 informatique à l'ULB
>>
>>
>> _______________________________________________
>> Pharo-project mailing list
>> [email protected]
>> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>
>
> _______________________________________________
> Pharo-project mailing list
> [email protected]
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>
_______________________________________________
Pharo-project mailing list
[email protected]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project