Difference between revisions of "W1201 Scope"
From Coder Merlin
Line 82: | Line 82: | ||
let x = 21 | let x = 21 | ||
print(x) | print(x) | ||
} | } // | ||
</syntaxhighlight> | </syntaxhighlight> | ||
} | } | ||
Line 99: | Line 99: | ||
let x = 21 | let x = 21 | ||
print(x) | print(x) | ||
} | } // | ||
print(x) | print(x) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Line 117: | Line 117: | ||
let x = 21 | let x = 21 | ||
print(x) | print(x) | ||
} while x == 21 | |||
print(x) | print(x) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Line 135: | Line 135: | ||
let x = 21 | let x = 21 | ||
print(x) | print(x) | ||
} | } // | ||
print(x) | print(x) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Line 154: | Line 154: | ||
let x = x + 10 | let x = x + 10 | ||
print(x) | print(x) | ||
} | } // | ||
print(x) | print(x) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Line 173: | Line 173: | ||
x = x + 10 | x = x + 10 | ||
print(x) | print(x) | ||
} | } // | ||
print(x) | print(x) | ||
</syntaxhighlight> | </syntaxhighlight> |
Revision as of 14:26, 25 February 2019
Within these castle walls be forged Mavens of Computer Science ...
— Merlin, The Coder
Scope[edit]
Research[edit]
- Read Scope (Wikipedia)
- Read Computer Science I Textbook (by Bourke) Chapter 2.2.4. Scoping
Experiment[edit]
Create a directory within your "project" directory.
cd ~/projects
mkdir project-1201
cd project-1201
Edit a new file named "main.swift"
emacs main.swift
For this project you'll repeatedly edit the same file. It's probably easiest to test this file within emacs by typing: M-& (async-shell-command) and observing the results. For each question, be sure to understand the behavior before proceeding to the next question. It will be helpful to record your answers and reasoning for later review.