タグ

ブックマーク / www.angelfire.com (1)

  • Shapes OO example: R Code

    setClass("shape", representation(x="numeric", y="numeric"), prototype(x=0, y=0) ) # accessors for x & y setGeneric("getX", function(this) standardGeneric("getX")) setMethod("getX", "shape", function(this) { this@x } ) setGeneric("getY", function(this) standardGeneric("getY")) setMethod("getY", "shape", function(this) { this@y } ) setGeneric("setX<-", function(this, value) standardGeneric("setX<-")

    ma_ko
    ma_ko 2007/11/10
    Rでオブジェクト指向プログラミングを実現させると、の例/ S4 method
  • 1