From: Rick DeNatale Date: 2006-09-03T06:09:29+09:00 Subject: Re: a selfish ruby question On 9/1/06, Dave Rose wrote: > Phrogz wrote: > > You can't have an explicit receiver for private methods. See below. > in trying to understand this.... > why is it then the Array.select instance method is private? here?.... It's not. Quoting from your original post > grr.arte.astop(b[0]) >NoMethodError: undefined method `astop' for # > from (irb):143 > from :0 Here grr.arte is returning an Array, and Array doesn't have an astop method. > grr.astop([b0]) >NameError: undefined local variable or method `b0' for main:Object > from (irb):144 > from :0 Did you mean to say b[0] instead of b0? > grr.astop(b[0]) > NoMethodError: private method `select' called for # > from (irb):140:in `astop' > from (irb):145 > from :0 I guess that you've defined select as a private method in Akill or one of it's superclasses. It's not complaining about select being a private method of Array, but of Akill. As has been pointed out, it's illegal to use an explicit receiver on private methods. This is the way that the Ruby runtime enforces privacy. So self.publicMethod is the same as just publicMethod but privateMethod works and self.privateMethod raises an exception. -- Rick DeNatale My blog on Ruby http://talklikeaduck.denhaven2.com/