From: "Mauricio Fernández" Date: 2003-06-17T20:00:32+09:00 Subject: Re: multiple blocks or proc arguments to method On Tue, Jun 17, 2003 at 06:57:41AM +0900, Alexander Schofield wrote: > > A> What version are you using? I get: > > > > 1.8 > > > > A> Was there a change in 1.7 or 1.8 with this behavior? What would the > > A> behavior be if "a" had used an instance variable that had been aliased > > A> to something else in B, or a private instance variable of A? > > > > I don't know what is a "private instance variable". > > Sorry I meant accessor method. Specifically, if the instance method > of A used an accessor method (defined in A that was private), bound to > an instance of B would it work? And would the bound instance method > have polymorphic behavior-- if for example I redefined the accessor > method in B which would bound method use (and would scope make any > difference with this)? Ruby always behaves "polymorphically" (sp?). It's going to send the message to self and find the right method. bash-2.05a$ cat a.rb #!/usr/bin/ruby class A attr_reader :foo def initialize @foo = "A" end def a(b) p "A#a #{b} #{foo}" end end class B < A attr_reader :foo def initialize @foo = "B" end def a(b) p "B#a #{b} #{foo}" end end a = A.instance_method("a") p a a.bind(B.new)[12] bash-2.05a$ ruby a.rb # "A#a 12 B" -- _ _ | |__ __ _| |_ ___ _ __ ___ __ _ _ __ | '_ \ / _` | __/ __| '_ ` _ \ / _` | '_ \ | |_) | (_| | |_\__ \ | | | | | (_| | | | | |_.__/ \__,_|\__|___/_| |_| |_|\__,_|_| |_| Running Debian GNU/Linux Sid (unstable) batsman dot geo at yahoo dot com How many chunks could checkchunk check if checkchunk could check chunks? -- Alan Cox