之前在寫Rails的時候還不是很熟悉Ruby,所以很多Ruby的特性沒有去深究。最近剛考完期末考比較有時間了,所以好好來看了一下Ruby。目前覺得學Ruby的好處就是會讓我想去比較Python,因為我個人還是Python的愛好著,所以看Ruby可以做到的功能就想要看Python可不可以做到。拿Ruby最有名的名能之一來說好了: Monkey Patching,從Wikipedia: A monkey patch is a way to extend or modify the run-time code of dynamic languages without altering the original source code . Ruby 可以很容易的動在舊有的Class/Module中加入新的Class/Method,舉例來說我們可以新增一個 method 到 Array 中: def Array.test puts "This is a singleton method `test' of the Array class" end