Updated "filter" example

Signed-off-by: Olivier Ligot <oligot@gmail.com>
This commit is contained in:
Jocelyn Fiat
2012-10-08 09:24:19 +02:00
parent 016efaed15
commit 146fd3cc7d
2 changed files with 27 additions and 0 deletions

View File

@@ -18,6 +18,8 @@ feature -- Initialization
create users.make (10) create users.make (10)
create l_user.make (1, "foo", "bar") create l_user.make (1, "foo", "bar")
users.put (l_user, l_user.id) users.put (l_user, l_user.id)
create l_user.make (2, "demo", "demo")
users.put (l_user, l_user.id)
end end
feature -- Access feature -- Access

View File

@@ -7,6 +7,12 @@
class class
USER USER
inherit
ANY
redefine
is_equal
end
create create
make make
@@ -34,6 +40,25 @@ feature -- Access
password: STRING password: STRING
-- Password -- Password
foo_: STRING
do
ensure
anchor: False
end
feature -- Comparison
is_equal (other: like Current): BOOLEAN
-- Is `other' attached to an object considered
-- equal to current object?
do
if Current = other then
Result := True
else
Result := (id = other.id) and (name = other.name) and (password = other.password)
end
end
;note ;note
copyright: "2011-2012, Olivier Ligot, Jocelyn Fiat and others" copyright: "2011-2012, Olivier Ligot, Jocelyn Fiat and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"