Object#singleton_class

e$B$k$S$-$A$G$9!#e(B

e$B$=$m$=$mFC0[%/%i%[email protected]$k%a%=%C%I$rF3F~$7$F$bNI$$$N$G$O$J$$$G$7$g$&$+!)e(B
e$BKh2s!Ve(B(class << x; self;
end)e$B!W$H=q$/$N$OH~$7$/$J$$$G$9$+$i!#e(B

e$BL>A0$O$=$N$^$^!Ve(BObject#singleton_classe$B!W$,$$$$$H;W$$$^$9!#e(B
e$B$=$7$FJLL>!Ve(BObject#eigenclasse$B!W!"!Ve(BObject#metaclasse$B!W$bM_$7$$$G$9!#e(B

class Object
def singleton_class
class << self; self; end
end
alias eigenclass singleton_class
alias metaclass singleton_class
end

x = “a”
class << x; self; end # => #<Class:#String:0xb7b2c700>
x.singleton_class # => #<Class:#String:0xb7b2c700>
x.eigenclass # => #<Class:#String:0xb7b2c700>
x.metaclass # => #<Class:#String:0xb7b2c700>

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

In message “Re: [ruby-dev:34191] Object#singleton_class”
on Tue, 1 Apr 2008 00:25:41 +0900, [email protected] writes:

|e$B$=$m$=$mFC0[%/%i%[email protected]$k%a%=%C%I$rF3F~$7$F$bNI$$$N$G$O$J$$$G$7$g$&$+!)e(B
|e$BKh2s!Ve(B(class << x; self; end)e$B!W$H=q$/$N$OH~$7$/$J$$$G$9$+$i!#e(B
|
|e$BL>A0$O$=$N$^$^!Ve(BObject#singleton_classe$B!W$,$$$$$H;W$$$^$9!#e(B
|e$B$=$7$FJLL>!Ve(BObject#eigenclasse$B!W!"!Ve(BObject#metaclasse$B!W$bM_$7$$$G$9!#e(B

e$B5$;}$A$OJ,$+$j$^$9$,!"L>A0$N9g0U$,$G$-$k$^$G$OF3F~$7$^$;$s!#e(B

  • singleton_classe$B"*e(Bsingletone$B%Q%?!<%s$KEP>l$9$k%/%i%9!"$H$/e(B
    e$B$KI8=`E:IU$Ne(Bsingleton.rbe$B$GDj5A$5$l$F$$$ke(BSingletone$B%/%i%9e(B
    e$B%H$N:.F1$,$&$l$7$/$J$$e(B

  • metaclase$B"%a%?%/%i%9$H$OEAE}E$K!V%/%i%9$N%/%i%9!W$r0UL#e(B
    e$B$9$k$,!"e(BRubye$B$G$OFC0[%/%i%9$O$b$C$H9-$$e(B

  • eigenclasse$B"*$3$l$,0lHV32$,>/$J$$$,!"0UL#$,J,$+$k?M$O>/?te(B
    e$BGI$9$.$k5$$,$9$ke(B

e$B$H$$$&$o$1$G!"e(Bruby-talke$B$r4^$a$F7<LX3hF0$,I,MW$+$b$7$l$^$;$s!#e(B

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs