[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Ruby1.9, instance_eval and private methods

Victor 'Zverok' Shepelev

4/24/2008 1:21:00 PM

Can somebody please explain this:

class A
end

blk = proc do
def test
puts 'test'
end
end

a1 = A.new

a1.instance_eval &blk
a1.test #=> prints "test"

def indirect(a, &blk)
a.instance_eval &blk
end

a2 = A.new

indirect(a2, &blk)

a2.test #=> private method `test' called for #<A:0xad519c> (NoMethodError)

In words: when block for instance_eval is passed through several levels of
methods, it evaluates into private methods.

Ruby1.9 version 2008-03-29

in Ruby1.8 both a1.test and a2.test work as expected


6 Answers

3800 Dead

9/28/2007 2:01:00 PM

0

On 28 Sep 2007 10:24:23 GMT, Amanda Williams <pms@fu.com> wrote:

>3800 Dead <zepp22113800@finestplanet.com> allegedly said in
>news:r7oof3h0i26escgs5hf90gdta8n28t6puc@4ax.com:
>
>> On Thu, 27 Sep 2007 17:54:52 -0700, "Harry Dope"
>> <DumbassliberalShill@aol.com> wrote:
>>
>>>Hillary OK With Second-Grade Teacher Reading Gay Prince Fairy Tale
>>
>> I note that not only where all the other Democratic candidates far
>> more vigorous in their support of the book, but that two leading
>> Republicans -- Guilliani and Romney -- have also signed off on it.
>> It's weird how this goof singles her out for supporting it when her
>> support is more tepid than any other Democrat and even some
>> Republicans.
>
>Note that THIS narcoleptic crap is all the reichtard idiots have... direct
>from (big surprise) FUX "noise" to your desk...
>
>But it's troubling ... does this mean we can't count on the bigot and
>christo-fascist vote in '08 ????
>
>gee.. I dunno what we are going to do now... <snicker>

Well, we COULD target the rest of the population, which would be
anyone with an IQ over 50.
--

One of the [Gold Star mothers], Elaine Johnson, recounted a meeting that she had with
President Bush in which he gave her a presidential coin and told her
and five other families: "Don't go sell it on eBay."

--from interview broadcast on NPR

Putsch: leading America to asymetric warfare since 2001

Not dead, in jail, or a slave? Thank a liberal!
Pay your taxes so the rich don't have to.
For the finest in liberal/leftist commentary,
http://www.zeppscommen...
For news feed (free, 10-20 articles a day)
http://groups.yahoo.com/subscribe/...
For essays (donations accepted, 2 articles/week)
http://groups.yahoo.com/subscribe/ze...

a.a. #2211 -- Bryan Zepp Jamieson

ts

4/24/2008 1:28:00 PM

0

Victor 'Zverok' Shepelev wrote:
> Can somebody please explain this:

no, probably not :-)

> Ruby1.9 version 2008-03-29

probably a bug.

Guy Decoux

Robert Dober

4/24/2008 6:50:00 PM

0

On Thu, Apr 24, 2008 at 3:27 PM, ts <decoux@moulon.inra.fr> wrote:
> > Ruby1.9 version 2008-03-29
>
> probably a bug.
Guy do you think that Victor should file a bug report, I strongly
believe that this would be helpful.

Robert

ts

4/25/2008 8:04:00 AM

0

Robert Dober wrote:
> Guy do you think that Victor should file a bug report, I strongly
> believe that this would be helpful.

no, this is a known problem because it's already corrected in my
private version


Guy Decoux

Robert Dober

4/25/2008 8:45:00 AM

0

On Fri, Apr 25, 2008 at 10:03 AM, ts <decoux@moulon.inra.fr> wrote:
> Robert Dober wrote:
> > Guy do you think that Victor should file a bug report, I strongly
> > believe that this would be helpful.
>
> no, this is a known problem because it's already corrected in my
> private version
>
ok that's why I asked, there was no bug for this on Rubyforge's tracker, right?
Thx
Guy
--
http://ruby-smalltalk.blo...

---
Whereof one cannot speak, thereof one must be silent.
Ludwig Wittgenstein

ts

4/25/2008 8:48:00 AM

0

Robert Dober wrote:
> ok that's why I asked, there was no bug for this on Rubyforge's tracker, right?

Well, each time that you see 'instance_eval &block' you can expect
a bug and this was reported in rubyforge

Guy Decoux