Skip to content

Commit d451bed

Browse files
markdown improvements
1 parent 76e34d1 commit d451bed

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

lexicalscoping.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,20 +73,20 @@ crazy <- function() {
7373
3.14
7474
42
7575
42
76-
> x # variable `x` outside of the function its updated value after the first statement within function crazy()
76+
> x # variable `x` outside of the function its updated value after the first statement within function `crazy()`
7777
[1] 3.14
7878
```
7979

80-
The first two print() statements use the variable `x` in the containing environment, as no local variable `x` exists at the moment, which has been updated from x <- 0 to x <- 3.14 via x <<- 3.14 inside function crazy().
80+
The first two `print()` statements use the variable `x` in the containing environment, as no local variable `x` exists at the moment, which has been updated from `x <- 0` to `x <- 3.14` via `x <<- 3.14` inside function `crazy()`.
8181

8282
The third print() statement uses the variable `x` just created by the preceding assignment statement x <- 42 which causes the containing environment not to be searched unlike the first and second print() statements.
8383

8484
The fourth print() statement uses the variable `x` which exists within the function because the x <- 42 now masks access, at least for anything other than the super-assignment operator, to the containing environment’s variable `x`.
8585

86-
I added a call to variable `x` after the function crazy() returns to show it keeps the new value assigned to it by the super-assignment operator inside function crazy().
86+
I added a call to variable `x` after the function `crazy()` returns to show it keeps the new value assigned to it by the super-assignment operator inside function `crazy()`.
8787

8888
The super-assignment operator does not update a variable of the same name inside an inner function but the innermost environment inherits any changes unless a local variable of the same name exists within the inner function as demonstrated by x <- 42; print(x) and print(x).
89-
Furthermore, if a variable named `x` had existed inside function crazy() and preceded the call to the super-assignment operator, the results would be as shown in the next example.
89+
Furthermore, if a variable named `x` had existed inside function `crazy()` and preceded the call to the super-assignment operator, the results would be as shown in the next example.
9090

9191
```R
9292
crazy <- function() {

0 commit comments

Comments
 (0)