David Flanagan <david / davidflanagan.com> writes:
> Steven Lumos wrote:
>> Maybe I'm confused, which of these are you talking about?
>>
>> class A
>>   def m; @f(); end
>>   def @f; true; end
>> end
>>
>> class B < A
>> end
>>
>> B.new.m  #=> Error: The mighty class author requires that you
>>              reimplement @f.
>>
>> or
>>
>> class B < A
>>   def @f; false; end
>>   #=> Error: The mighty class author forbids you to reimplement @f
>> end
>>
>> Steve
>>
>>
>
> Steve,
>
> I don't intend either of those, really.  My proposal is that the
> method @f would be completely local to the defining class.  There is
> no inheritance of these hypothetical methods, and so the class
> hierarchy is irrelevant.  If you try to invoke @f in a class B that
> does not define @f you get a NoMethodError or whatever. And you can
> define @f in a class B regardless of what is defined in the
> superclass, so you'd never get an error message like your second one.

I think I get it now.

class B < A; end
B.new.m  #=> true

class B < A
  def m; @f(); end
end
B.new.m  #=> NoMethodError

class B < A
  def @f; false; end
end
B.new.m  #=> true

class B < A
  def m; @f(); end
  def @f; false; end
end
B.new.m  #=> false

Steve