RubyµÄ×°ÊÎÆ÷ģʽʵÏÖ
class Tree
def initialize
puts "Make a normal tree"
end
def decorate
puts "Make sure the tree won\'t fall"
end
end
class RedBalls < Tree
def initialize(tree)
@parent = tree;
end
def decorate
@parent.decorate
puts "Put on some red balls"
end
end
class BlueBalls < Tree
def initialize(tree)
@parent = tree;
end
def decorate
@parent.decorate
puts "Add blue balls"
end
end
class Angel < Tree
def initialize(tree)
@parent = tree;
end
def decorate
@parent.decorate
puts "An angel on the top"
end
end
tree = Angel.new(BlueBalls.new(RedBalls.new(Tree.new)))
tree.decorate
Ïà¹ØÎĵµ£º
Ruby 101£º·½·¨¶ÔÏó
Written by Allen Lee
´Ó·½·¨µ÷ÓÃ˵Æð
ÔÚÉÏһƪÎÄÕÂÀÎÒÃÇ¿´µ½µ÷ÓöÔÏóµÄ·½·¨ÊµÖÊÉÏÊÇÏò¶ÔÏó·¢ËÍÏûÏ¢£¬ÏÂÃ棬ÎÒÃÇÔÙÀ´¿´Ò»¸öÓÐȤµÄÓ¦Óá£ÔÚRubyÀ×Öµä¿ÉÒÔͨ¹ý {key => value} À´´´½¨£¬Èç¹ûÄãʹÓõİ汾ÊÇ1.9»òÒÔÉÏ£¬µ±keyµÄÀàÐÍÊÇSymbolʱ£¬´´½¨×ÖµäµÄÓ ......
While looking for information on the subject, I looked into the ONLamp article Extending Ruby with C by Garrett Rooney, the Extending Ruby chapter in the Pickaxe, README.EXT (located at /usr/share/doc/ruby1.8-dev/README.EXT.gz on my Ubuntu system) and got some help from Kjetil.
The resulting file c ......
<!--
/* Font Definitions */
@font-face
{font-family:ËÎÌå;
panose-1:2 1 6 0 3 1 1 1 1 1;
mso-font-alt:SimSun;
mso-font-charset:134;
mso-generic-font-family:auto;
mso-font-pitch:variable;
mso-font-signature:3 680460288 22 0 262145 0;}
@font-face
{font-family:"Cambria Mat ......
¹«Ë¾ÀïÔ½À´Ô½¶àµÄ½Ó¿ÚÒÔICE·½Ê½ÌṩÁË£¬ÒÔǰû½Ó´¥¹ý£¬ËùÒÔÎÒÕâÁ½ÌìÒ²³éÁ˵ãʱ¼äÑо¿ÁËÏÂICE£¬²Î¿¼ÁËÍøÉϺܶàÌû×Ó£¬²ÅÖÕÓÚÅÜͨµÚÒ»¸ö¼òµ¥µÄICE
½ÓÏÂÀ´ÌùÉÏÎÒËùÓл·¾³µÄ´î½¨¹ý³ÌÒÔ¼°´úÂ룬ºÍ´ó¼Ò·ÖÏíÏÂICEËù´øÀ´µÄ¿ìÀÖ
ICEÊÇʲôÎҾͲ»¶à˵ÁË
1¡¢ Ò»¿î¸ßÐÔÄܵÄÖмä¼þ£¬»ùÓÚICE¿ÉÒÔʵÏÖµçÐż¶µÄ½ ......