asSet asOrderedCollection

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

asSet asOrderedCollection

mbreitha
Hello,
I would like to know if is possible to delete doubledbloom in an
orederedCollection when it's composed by Objects. I've tried with asSet
but it doesn't work with Objects.
thanks for your answer

Maxime B.

_______________________________________________
Seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: asSet asOrderedCollection

Esteban A. Maringolo
On 5/18/06, mbreitha <[hidden email]> wrote:
> Hello,
> I would like to know if is possible to delete doubledbloom in an
> orederedCollection when it's composed by Objects. I've tried with asSet
> but it doesn't work with Objects.
> thanks for your answer

What kind of objects are you trying to condense in a Set?

If they are your domain objects, check the implementation of #= and
#hash. (Look for other implementator to understand its behavior).

As a rule of thumb I recommend you that each time you implement #= in
your object also implement #hash using the same criteria.

Perhaps your problem is that your objects doesn't implement the method
with selector #= (nor #hash).

To play with, instance two of your objects and compare them using:
objectA = objectB
objectA hash = objectB hash

If both are equal, those evaluations must answer true.

Regards,


--
Esteban A. Maringolo
[hidden email]
_______________________________________________
Seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: asSet asOrderedCollection

mbreitha
In reply to this post by mbreitha
On 5/18/06, mbreitha <max at bouh.org> wrote:
> Hello,
> I would like to know if is possible to delete doubledbloom in an
> orederedCollection when it's composed by Objects. I've tried with asSet
> but it doesn't work with Objects.
> thanks for your answer
---------------------------------------------------------------
What kind of objects are you trying to condense in a Set?

If they are your domain objects, check the implementation of #= and
#hash. (Look for other implementator to understand its behavior).

As a rule of thumb I recommend you that each time you implement #= in
your object also implement #hash using the same criteria.

Perhaps your problem is that your objects doesn't implement the method
with selector #= (nor #hash).

To play with, instance two of your objects and compare them using:
objectA = objectB
objectA hash = objectB hash

If both are equal, those evaluations must answer true.

Regards,
-------------------------------------------------------------
My objects are:
Fait new boolean:#red.
Fait new boolean:#red.

I have done the two evaluations and with : Fait new boolean:#red = Fait
new boolean:#red, I get True.
Also, if I do the evaluation with hash, the result is False.
I don't understand ????

my fonction = is:
= aFait
^self boolean = aFait boolean


_______________________________________________
Seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Re: asSet asOrderedCollection

Damien Cassou-3
> My objects are:
> Fait new boolean:#red.
> Fait new boolean:#red.
>
> I have done the two evaluations and with : Fait new boolean:#red = Fait
> new boolean:#red, I get True.
> Also, if I do the evaluation with hash, the result is False.
> I don't understand ????
>
> my fonction = is:
> = aFait
> ^self boolean = aFait boolean

I think you should write a new method in Fait:

Fait>>hash
   ^ boolean hash

--
Damien Cassou

_______________________________________________
Seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Re: asSet asOrderedCollection

stephane ducasse
In reply to this post by mbreitha
Strange code guy

> My objects are:
> Fait new boolean:#red.

A boolean: being a symbol... Berk!

> I have done the two evaluations and with : Fait new boolean:#red =  
> Fait
> new boolean:#red, I get True.

true?
Pay attention to the parentheses also

(Fact new boolean: #red) = (Fact new boolean: #red)

is not the same as

Fact new boolean: #red = Fact new boolean: #red

Also use the force, luke put a self halt in the code :)

> Also, if I do the evaluation with hash, the result is False.
> I don't understand ????
>
> my fonction = is:
> = aFait
> ^self boolean = aFait boolean
>
>
> _______________________________________________
> Seaside mailing list
> [hidden email]
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>

_______________________________________________
Seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Re: asSet asOrderedCollection

stephane ducasse
In reply to this post by Damien Cassou-3
Or you really have to think why to change the equality.
May be by design you should not have a fact in your base if it is  
already there.

Stef

On 18 mai 06, at 19:45, Damien Cassou wrote:

>> My objects are:
>> Fait new boolean:#red.
>> Fait new boolean:#red.
>> I have done the two evaluations and with : Fait new boolean:#red =  
>> Fait
>> new boolean:#red, I get True.
>> Also, if I do the evaluation with hash, the result is False.
>> I don't understand ????
>> my fonction = is:
>> = aFait
>> ^self boolean = aFait boolean
>
> I think you should write a new method in Fait:
>
> Fait>>hash
>   ^ boolean hash
>
> --
> Damien Cassou
>
> _______________________________________________
> Seaside mailing list
> [hidden email]
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>

_______________________________________________
Seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside