module StringExtensions refine String do def reverse "esrever" end end end module StringStuff using StringExtensions p "my_string".reverse #=>"esrever" end p "my_string".reverse #=>"gnirts_ym"
Ruby的细化(refine关键字)
原文:http://www.cnblogs.com/nightcatcher/p/6366319.html