R: operator overloading in zoo object
===

in R, how to implment operator overloading( like +,-, *./) for new class? I checked source code of zoo library, in ops.R, is the following code does this job? how does it work? 

Ops.zoo <- function (e1, e2) 

    {
        e <- if (missing(e2)) {
            NextMethod(.Generic)
        }
        else if (any(nchar(.Method) == 0)) {
            NextMethod(.Generic)
        }
        else {
    	merge(e1, e2, all = FALSE, retclass = NULL)
            NextMethod(.Generic)
        }
        out <- if (is.null(attr(e, "index"))) 
    	zoo(e, index(e1), attr(e1, "frequency"))
        else
    	e
        # the next statement is a workaround for a bu g in R
    	structure(out, class = class(out))
    }