Skip to content

Commit 11a3ba5

Browse files
committed
Use set_alt to in set instead of a 2nd assignment
1 parent 8870147 commit 11a3ba5

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

cachematrix.R

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ makeCacheMatrix <- function(x = matrix()) {
2020
# If altx is already set (non-NULL), then we're invalidating the cache;
2121
# otherwise we're just initializing it.
2222
if (!is.null(altx)) message("invalidating cache")
23-
altx <<- NULL
23+
set_alt(NULL)
2424
}
2525

2626
# getter for `x` in the parent scope
@@ -35,7 +35,6 @@ makeCacheMatrix <- function(x = matrix()) {
3535
list(set=set, get=get, set_alt=set_alt, get_alt=get_alt)
3636
}
3737

38-
3938
# The `cacheSolve` function returns the cached inverse of the matrix inside the
4039
# scope accessed by the functions in `x`, solving and caching the inverse if it
4140
# does not already exist.

0 commit comments

Comments
 (0)