Reputation: 61
I am having a problem comparing two objects in a HASH_TABLE
PERSON is a class with attributes such as name, b-day, status of relationship, spouse name, spouse id. So basically composed of attributes code:
list: HASH_TABLE[PERSON, INTEGER_64]
put(id1, id2: INTEGER_64)
local
p1, p2: PERSON
do
p1 := model.list.at(id)
-- or
p1 := model.list.search(id)
p1 := model.list.found_item -- same error as below
end
error: Source of assignment is not compatible with target.
THE FEATURES USED RETURN "DETACHABLE G"
I think I should be doing "if attached" to ensure item feature returns the correct object type and then assign? I'm not exactly sure how to cast the object though.
The error is triggered by calling above feature
The reason i need these functions to work is that I can sort easier
Upvotes: 0
Views: 122
Reputation: 5810
The features return detachable G
because it is possible that no element is found. Therefore you need to use object tests, e.g.
if
attached model.list [id1] as p1 and then
attached model.list [id2] as p2
then
... -- use p1 and p2
end
Upvotes: 2