Whoops! Here is the updated code:

julia> type Foo
       x::Int
       end

julia> import Base: ==

julia> ==(f1::Foo, f2::Foo) = f1.x == f2.x
== (generic function with 85 methods)

julia> foos = [Foo(4), Foo(4)]
2-element Array{Foo,1}:
 Foo(4)
 Foo(4)

julia> unique(foos)
2-element Array{Foo,1}:
 Foo(4)
 Foo(4)

julia> unique(foos)[1] == unique(foos)[2]
true




On Thursday, July 16, 2015 at 9:33:26 AM UTC-4, milktrader wrote:
>
> How did you get  foos?
>
> On Thursday, July 16, 2015 at 9:16:01 AM UTC-4, Marc Gallant wrote:
>>
>> The unique function doesn't appear to work using iterables of custom 
>> composite types, e.g.,
>>
>> julia> type Foo
>>        x::Int
>>        end
>>
>> julia> import Base: ==
>>
>> julia> ==(f1::Foo, f2::Foo) = f1.x == f2.x
>> == (generic function with 85 methods)
>>
>> julia> unique(foos)
>> 2-element Array{Foo,1}:
>>  Foo(4)
>>  Foo(4)
>>
>> julia> unique(foos)[1] == unique(foos)[2]
>> true
>>
>>
>> Is this the intended behaviour?
>>
>

Reply via email to