by Stephen Persson >> Mon, 21 Aug 2000 22:15:49 GMT
Hi,
I'm having problems with the collection.includes() method. I always thought this checked the OBJECT regardless of the key for that object within the collection. However this doesn't appear to be the case.
I have the following piece of code:
if not rProcessor.rAllScheduledJobsByTS.includes(self) then
rProcessor.rAllScheduledJobsByTS.add(self);
endif;
Where rProcessor is a job processor that has a collection of jobs to process, keyed by the timestamp when the job should start.
If a job is already in the queue, but I change the time it should start, based on the above code it should not add it to the queue again - right? Wrong - it does. And continues to do so everytime I change the start time. So I end up with the same instance in the collection numerous times (Using write statement, can see same oid added to collection everytime).
But, if I change the start time back to one of the previous times, it doesn't add it to the collection again.
ie, the includes method seems to be checking the object by looking up its key (timestamp). If same object with same key is present, includes() returns true, but if the same object is present with a different key it returns false.
Stephen Persson
Kinetix Group Ltd