Replaced assignment attempt with object test.

Author:halw
Date:2012-04-06T21:34:51.000000Z


git-svn-id: https://svn.eiffel.com/eiffel-org/trunk@1063 abb3cda0-5349-4a8f-a601-0c33ac3a8c38
This commit is contained in:
halw
2012-04-06 21:34:51 +00:00
parent 0b1d859156
commit fef1f1d302

View File

@@ -60,12 +60,10 @@ Another problem is that to do any <code>CAT</code> things with an item in the li
my_cats.item.purr -- Is invalid
</code>
This is because "item" is type <code>ANY</code> and although it may be currently attached to an instance of <code>CAT</code>, the static typing system cannot guarantee that. So you must use assignment attempt as we saw in the polymorphism example in [[Inheritance|Inheritance]] .
This is because "item" is type <code>ANY</code> and although it may be currently attached to an instance of <code>CAT</code>, the static typing system cannot guarantee that. So you must use an object test as we saw in the polymorphism example in [[Inheritance|Inheritance]] .
<code>
some_cat: CAT
...
some_cat ?= my_cats.item
if some_cat /= Void then
if attached my_cats.item as some_cat then
some_cat.purr
end
</code>