看板 Ruby 關於我們 聯絡資訊
http://jicksta.com/articles/2007/08/29/superators-add-new-operators-to-ruby 非常有趣的東西. 網頁上的兩個例子: class Array superator "<---" do |operand| self << operand.reverse end end ["jay"] <--- "spillihp" 與 class String superator "++" do |operand| upcase + operand.upcase end superator "-~+~-" do |operand| puts "Using pretty superators" self + operand end end p "Tangy" ++ "Erlangy" p "Super" -~+~- "ators" -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 211.76.240.242
godfat:我想不到這要怎麼做﹍﹍敗了 XD 翻 soruce code 中 09/01 00:11