You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: lexicalscoping.md
+28-28Lines changed: 28 additions & 28 deletions
Original file line number
Diff line number
Diff line change
@@ -48,7 +48,7 @@ getting cached data
48
48
49
49
Understanding the concepts in terms of the behaviour of the two functions takes more than a few minutes because you have to not only read the existing exemplar functions but take some time to play with the functions. Often seeing the code in action is more helpful than reading a chapter about lexical scoping.
50
50
51
-
Variable `m` is declared uniquely in both functions and are allocated separate addresses in memory. In function makeVector() you’ll notice variable `m` is declared immediately and assigned the value NULL using the standard assignment operator (`<-`). However, the `set` functions defined within the containing makeVector() function require the special assignment operator (`<<–`) to update the value of variable `m`; it is important to remember variable m was declared and initialised by makeVector().
51
+
Variable `m` is declared uniquely in both functions and are allocated separate addresses in memory. In function makeVector() you’ll notice variable `m` is declared immediately and assigned the value NULL using the standard assignment operator (`<-`). However, the `set` functions defined within the containing `makeVector()` function require the special assignment operator (`<<–`) to update the value of variable `m`; it is important to remember variable `m` was declared and initialised by `makeVector()`.
52
52
53
53
Had functions `set()` and `setmean()` not used the special assignment operator, these functions would have allocated memory to store the value and labelled the address as `m`. The variables named `m` would effectively be isolated and distinct variables.
0 commit comments