Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e0f275f

Browse files
committed
Change getMatrix/setMatrix to get/set
to be more consistent with sample code.
1 parent 022c2ef commit e0f275f

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

cachematrix.R

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
1-
## Pair of function that compute/cache the inverse of a matrix.
1+
## Pair of functions that compute/cache the inverse of a matrix.
2+
## (Or, more generally, computes/caches the result of the solve() function.)
23

34
## This function creates a special "matrix" object that can cache its inverse.
45
makeCacheMatrix <- function(x = matrix()) {
56
s <- NULL
6-
setMatrix <- function(y) {
7+
set <- function(y) {
78
x <<- y
89
s <<- NULL
910
}
10-
getMatrix <- function() x
11+
get <- function() x
1112
setSolve <- function(sol) s <<- sol
1213
getSolve <- function() s
13-
list(setMatrix = setMatrix, getMatrix = getMatrix,
14+
list(set = set, get = get,
1415
setSolve = setSolve, getSolve = getSolve)
1516

1617
}
@@ -27,7 +28,7 @@ cacheSolve <- function(x, ...) {
2728
message("getting cached data")
2829
return(s)
2930
}
30-
data <- x$getMatrix()
31+
data <- x$get()
3132
s <- solve(data, ...)
3233
x$setSolve(s)
3334
s

0 commit comments

Comments
 (0)