From: Josh Cheek Date: 2010-02-13T08:24:23+09:00 Subject: Re: [noob] Problem with arrays --000e0cd13928deed71047f6f6fed Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable On Fri, Feb 12, 2010 at 12:03 PM, Luc Heinrich wrote: > On 12 f=E9vr. 2010, at 18:10, Marnen Laibow-Koser wrote: > > > You don't need the parentheses or the "=3D=3D false". You probably jus= t > > want "while !@finished". > > Even better: until @finished > > > if !f.collide_with?(c) > > Same here: unless f.collide_with?(c) > > -- > Luc Heinrich - luc@honk-honk.com > > > I would also define getters for boolean variables def finished? !!@finished end ... until finished? ... end I try to restrict direct references to instance variables, and instead use them through methods, it seems like better encapsulation to me. For example= , maybe later I realize I can tell if it is finished by checking something else rather than storing state in an instance variable, then there is only the setter and getter methods that need to be looked at, rather than every place I used the instance variable. I guess I see the method as an interface to the functionality, and the instance variable as the implementation. --000e0cd13928deed71047f6f6fed--