Skip to content

Commit 4f17798

Browse files
author
Jonas Friedemann Grote
committed
Improve comments.
1 parent 226cd4e commit 4f17798

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

cachematrix.R

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
## Put comments here that give an overall description of what your
22
## functions do
33

4-
## Create a matrix that will cache its inverse.
4+
## Create a matrix wrapping function ("object") that will cache the matrix's inverse.
55

66
makeCacheMatrix <- function(x = matrix()) {
77
inverse <- NULL
@@ -25,10 +25,13 @@ makeCacheMatrix <- function(x = matrix()) {
2525
cacheSolve <- function(x, ...) {
2626
inverse <- x$getinverse()
2727
if (!is.null(inverse)) {
28+
# inverse has been calculated already
2829
return(inverse)
2930
}
3031
data <- x$get()
32+
# actual solving
3133
inverse <- solve(data)
34+
# save inverse
3235
x$setinverse(inverse)
3336
inverse
3437
}

0 commit comments

Comments
 (0)