Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!uwm.edu!rpi!turing.cs.rpi.edu!adamsf From: adamsf@turing.cs.rpi.edu (Frank Adams) Newsgroups: comp.lang.smalltalk Subject: Re: Data-Hiding? Really?? Summary: Variables aren't objects Message-ID: <3$SQJ#@rpi.edu> Date: 18 Jan 90 02:55:50 GMT References: <4811d5e9.20b6d@apollo.HP.COM> Reply-To: adamsf@turing.cs.rpi.edu (Frank Adams) Organization: RPI CS Dept. Lines: 11 In article <4811d5e9.20b6d@apollo.HP.COM> yon@apollo.HP.COM (David Yon) writes: > You'll find that by setting the ripeness factor of the >anotherApple variable, it changed the state of the object in the >AppleBasket. So the ripeness of the Apple in the AppleBasket will >have been changed to five. On the surface, this appears to violate >the rule that only objects can change their own state. You're confusing variables and objects. When you get the Apple and assign it to anotherApple, you aren't creating a new Apple object. You are making anotherApple be the *same* Apple object as is in the collection. Naturally, whatever you do it will be visible however you get access to it.