Messages from list : cormas@cirad.fr

Choose a topic among the following archives :

Re: initialisation d'agents selon leurs IDs

New Message Reply Date view Thread view Subject view Author view

Subject: Re: initialisation d'agents selon leurs IDs
From: Bruno Locatelli (blocatel@catie.ac.cr)
Date: Tue May 18 2004 - 20:39:14 CEST

Hello,
If you select a subcollection from "theDemandeurs"...
> demandeurs := theDemandeurs select: [:demandeur | demandeur aCondition]

and change the attributes "demand" of each object of this subcollection...
>demandeurs do: [:demandeur | demandeur demande: 1]

you will not change the attributes of copies of your objects, but the attributes of the same objects as the ones from "theDemandeurs" (object-oriented language principle).

I think that your problem came from the condition you used:
> demandeurs:= theDemandeurs select: [:demandeur | (demandeur id = (0 rem: 3))].

As (0 rem: 3) is always equal to 0, it is equivalent to:
> demandeurs:= theDemandeurs select: [:demandeur | (demandeur id = 0 )].

As there may be no object with Id=0, your "demandeurs" may be an empty collection. It may explain why the second sentence has no effect on object attributes.

To resolve this kind of programming problems, you should use the debugger and inspect your objects (especially "demandeurs" which may be shown as empty).

Regards
   bruno
PS: as this list is international, could you please write in english, so that everybody may understand? Thanks !

  ----- Original Message -----
  From: Pierre-Marcel GORAL
  To: cormas@cirad.fr
  Sent: Tuesday, May 18, 2004 3:44 AM
  Subject: initialisation d'agents selon leurs IDs

  Bonjour à tous,

  Mon modèle se comporte de manière bizarre, probablement celà est du à une initialisation erronée, bien que s'exécutant. A l'initialisation, je veux pouvoir changer des attributs d'agents en fonction de leur n°ID. j'utilise pour cela des listes du type "theAgents" et des sous listes de ces listes qui correspondent à un select sur les ID. Un peu comme ceci:

  demandeurs := theDemandeurs select: [:demandeur | (demandeur id = (0 rem: 3))].
    demandeurs do: [:demandeur | demandeur demande: 1].

  MAIS, avec ce traitement, les agents theDemandeurs sont-ils eux aussi mis à jour, ou seulement leurs recopies dans "demandeurs"? J'ai bien l'impression que non... Dans ce cas, que puis-je faire pour mettre à jour les demandes des demandeurs de la liste theDemandeurs qui correspondent aux ID voulues?

  Je vous remercie par avance,

  Cordialement,

  Pierre-Marcel GORAL

------------------------------------------------------------------------------
  Bloquez les fenêtres pop-up, c'est gratuit ! Cliquez ici !

New Message Reply Date view Thread view Subject view Author view
 

Back to home