Skip to content

Commit

Permalink
Change name of referenced variable in loops example
Browse files Browse the repository at this point in the history
  • Loading branch information
asynchroza committed Dec 14, 2023
1 parent 207b175 commit a313bc7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Binary file removed Bozhilov-DT.docx
Binary file not shown.
8 changes: 4 additions & 4 deletions examples/loops.nula
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ for (def a = 5; a < 100; a * 2) {
}

# How to use references in a for loop
def referred = 1000;
def referencedVar = 1000;

# You're not required to dereference references in the initialization header
for (def a = &referred; a < 10000; a * 2) {
for (def a = &referencedVar; a < 10000; a * 2) {

# but you need to dereference when working with references in the body
a = *a + *a / 4; # NB: you're not required to dereference the identifier when assigning to it
Expand All @@ -18,5 +18,5 @@ for (def a = &referred; a < 10000; a * 2) {
log("The value of the referred variable is: ", a);
}

# 'referred' should reflect the changes applied to the reference 'a'
log(referred);
# 'referencedVar' should reflect the changes applied to the reference 'a'
log(referencedVar);

0 comments on commit a313bc7

Please sign in to comment.