Class#dup

e$B!!$5$5$@$G$9!%e(B

e$B!!e(Bruby-core e$B$N$[$&$Ge(B Class#dup
e$B$9$k$H;W$C$?DL$j$NF0:n$K$J$i$J$$!$$He(B
e$B$$$&%l%]!<%H$r$b$i$$$^$7$?!%e(B

class A
@@a = ‘A’
def a=(x)
@@a = x
end
def a
@@a
end
end

B = A.dup
B.new.a = ‘B’
p A.new.a #=> ‘B’
#=> 1.8.7 e$B$@$He(B ‘A’

e$B!!$[$H$s$I!$e(BClass#dup
e$B$N$3$H$r9M$($F$$$J$+$C$?$N$G$9$,!$$3$NLdBj$O??e(B
e$BLLL$K<h$j07$&I,MW$,$"$k$G$7$g$&$+!%Nc$($P!$e(BClass#dup
e$B$O%5%]!<%H$7$Je(B
e$B$$!$$H$$$&$N$b<j$+$H;W$$$^$9!%$d$O$j$3$l$OI,MW$J5!G=$@!$$H??LLL$K9Me(B
e$B$($k$J$i!$$,$i$j$HFbIt9=B$$rJQ99$9$kI,MW$,$"$j$^$9!%$b$7I,MW$J$i!$e(B
1.9.0-3 e$B$^$G$K4V$K9g$&$h$&$KJQ99$7$?$$$H;W$$$^$9!%e(B

e$B!!$A$J$$K!$<!$N$h$&$JNc$r;n$7$F$$?$H$3$m!$e(B1.8.7
e$B$G$OJQ$J%(%i!<$K$Je(B
e$B$j$^$7$?!%e(B

class A
Const = ‘A’
def foo
p Const
end
end

B = A.dup

class B
Const = ‘B’
end

p A::Const
A.new.foo
p B::Const
B.new.foo # 1.8.6 e$B0JA0!$e(B1.9.0 ‘A’
# 1.8.7 e$B$@$H%(%i!<!%$3$l$O%P%0$C$]$$!%e(B

e$B!!$5$5$@$G$9!%e(B

e$B!!$3$l!$$I$&$7$^$7$g$&!d$^$D$b$H$5$se(B