Skip to content
This repository was archived by the owner on Apr 13, 2023. It is now read-only.
This repository was archived by the owner on Apr 13, 2023. It is now read-only.

ceylon.time.Period compare and equals incompatible #708

@dlkw

Description

@dlkw
    value p1 = Period(0, 0, 0, 0, 0, 0, 10 * 60 * 60 * 1000);
    value p2 = p1.normalized();
    print(p1<=>p2); // prints "equal"
    print(p1==p2); // prints "false"

According to documentation of ceylon.language.Comparison, the <=> operator (compare method) must return equal if and only if the == (equals method) returns true.

At first sight, it is doubtful that the implementation of the equals method of class Period is correct, because semantically it should make no difference how a period is represented, only how long it takes. This is a bit difficult to decide, as explained in the documentation of the normalized method.

But, presumably, the equals method should also normalize its two operands before comparing the fields.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions