[Fw: Ruby question about irb]


#1

e$B$1$$$8$e!w$$$7$D$+$G$9e(B.

e$B0J2<$Ne(BURLe$B$Ge(B

http://www.ruby-forum.com/topic/168986#new

e$B2<5-$N$h$&$J<ALd$,>e$,$C$F$$$^$9e(B:

in irb

def why?
end
=> nil

Object.public_instance_methods.include?(“why?”)
=> true

in test.rb

def why?
end
p Object.private_instance_methods.include?(“why?”) # => true

e$B$Ge(B, e$B$3$l$Oe(B, irb e$B$GI>2A$K;H$C$F$$$ke(Bbinding e$B$,e(B:

binding = eval(“def irb_binding; binding; end; irb_binding”,
TOPLEVEL_BINDING)

e$B$@$+$i$J$s$G$9$,e(B, e$B$3$N$H$-e(B

eval(“def foo; end”, binding)

e$B$7$?$H$-e(B, fooe$B$,e(Bpublice$B$J$N$+e(Bprivatee$B$J$N$+$,e(B,
ruby1.8e$B7O$He(Bruby1.9e$B7O$H$G0c$Ce(B
e$B$F$$$Fe(B,

1.8e$B7O$G$Oe(B, public
1.9e$B7O$G$Oe(B, private

e$B$K$J$j$^$9e(B. e$B$3$l$C$Fe(B,
e$B$*8_$$$K;EMM$,0[$J$k$C$F$3$H$G$9e(B? e$B$=$l$H$be(B, e$B$Ie(B
e$B$A$i$+$N%P%0$J$s$G$9e(B?

__
---------------------------------------------------->> e$B@PDMe(B
e$B7=<ye(B <<—
---------------------------------->> e-mail: removed_email_address@domain.invalid <<—


#2

e$B$^$D$b$He(B e$B$f$-$R$m$G$9e(B

In message “Re: [ruby-dev:36969] [Fw: Ruby question about irb]”
on Tue, 28 Oct 2008 13:20:35 +0900, removed_email_address@domain.invalid (Keiju
ISHITSUKA) writes:

| eval(“def foo; end”, binding)
|
|e$B$7$?$H$-e(B, fooe$B$,e(Bpublice$B$J$N$+e(Bprivatee$B$J$N$+$,e(B, ruby1.8e$B7O$He(Bruby1.9e$B7O$H$G0c$Ce(B
|e$B$F$$$Fe(B,
|
| 1.8e$B7O$G$Oe(B, public
| 1.9e$B7O$G$Oe(B, private
|
|e$B$K$J$j$^$9e(B. e$B$3$l$C$Fe(B, e$B$*8_$$$K;EMM$,0[$J$k$C$F$3$H$G$9e(B? e$B$=$l$H$be(B, e$B$Ie(B
|e$B$A$i$+$N%P%0$J$s$G$9e(B?

e$B;EMM$,0[$J$j$^$9!#e(B1.8e$B$G$O%H%C%W%l%Y%k$+e(BObjecte$B$N%a%=%C%I$r:FDje(B
e$B5A$7$F$$$k$N$+$r6hJL$9$kJ}K!$,$"$j$^$;$s$G$7$?$,!“e(B1.9e$B$G$O6hJLe(B
e$B$G$-$k$N$G!”$h$j:F8=@-$r9b$a$?$H$$$&$3$H$G$9!#e(B