myCat.matrix <- function(..., sep=", ") {
cat("A matrix:
")
cat(..., sep=sep)
cat("")
}
myCat.default <- function(..., sep=", ") {
cat(..., sep=sep)
cat("")
}
setGenericS3("myCat")
myCat(1:10)
mat <- matrix(1:10, ncol=5)
myCat(mat)Run the code above in your browser using DataLab