シンプル: 必要なメソッドを提供するだけです:
plot.NewClass = function(x, y, ...) { … }
plot
最も簡単なケースでは、実装内の別のメソッドにディスパッチできます。
NewClass
オブジェクトが実際に変装したオブジェクトである場合histogram
は、次のトリックを使用できます。
plot.NewClass = function (x) {
# “unmask” histogram object
class(x) = 'histogram'
plot(x)
}