我學習Ruby和希望能夠做到這一點: Printer.hi there
,並有紅寶石輸出 "hi there"
到目前爲止,我有以下實現 class Printer
def method_missing(name, *args)
puts "#{name} #{args.join(',')}"
end
end
但這隻讓我做 Printer.hi "the
我正在尋找一種在Internet Exploder 7-9中執行node.classList.contains("foo")的方法,無需重構我的代碼的主要部分。這種方法存在於所有其他瀏覽器(甚至IE10)中。 我發現Code with classList does not work in IE?,但我不明白我將如何使用此替換.contains()方法。 我已經有代碼讓我爲某些瀏覽器運行隔離代碼,所
我定義動態Rails中類方法類方法: class << self
%w[school1 school2].each do |school|
define_method("self.find_by_#{school}_id") do |id|
MyClass.find_by(school: school, id: id)
end
end
end