Skip to content

Commit ddf9746

Browse files
committed
Merge branch 'abulfaiziqbal-master'
2 parents b45d81d + 577c61a commit ddf9746

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

cachematrix.R

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,16 @@
55
## matrix inversion calculations.
66

77
makeCacheMatrix <- function(x = matrix()) {
8-
inv <- NULL
8+
inverse <- NULL
99

1010
## Init object
1111
set <- function(y) {
1212
x <<- y
13-
inv <<- NULL
13+
inverse <<- NULL
1414
}
15-
get <- function() x
16-
setinverse <- function(solve) inv <<- solve
17-
getinverse <- function() inv
15+
get <- function() return(x)
16+
setinverse <- function(inv) inverse <<- inv
17+
getinverse <- function() return(inverse)
1818
list(set = set,
1919
get = get,
2020
setinverse = setinverse,
@@ -26,13 +26,13 @@ list(set = set,
2626

2727
cacheSolve <- function(x, ...) {
2828
## Return a matrix that is the inverse of 'x'
29-
inv <- x$getinverse()
30-
if(!is.null(inv)) {
29+
inverse <- x$getinverse()
30+
if(!is.null(inverse)) {
3131
message("getting cached inverse matrix")
32-
return(inv)
32+
return(inverse)
3333
}
3434
data <- x$get()
35-
inv <- solve(data, ...)
36-
x$setinverse(inv)
37-
inv
35+
inverse <- solve(data, ...)
36+
x$setinverse(inverse)
37+
return(inverse)
3838
}

0 commit comments

Comments
 (0)