Skip to content

Commit f20d0fd

Browse files
Fixed incorrect line numbers in 08-defensive.md
The line numbers referred to in the normalize_rectangle function of defensive programming were incorrect. My guess is the comment line was added later, and the line numbers were not updated. I corrected "The preconditions on lines 2, 4, and 5 catch invalid inputs:" to be "The preconditions on lines 3, 5, and 6 catch invalid inputs:" and "...we realize that line 10..." to be "...we realize that line 11..." Also added the line numbers for the post-conditions "The post-conditions on lines 17 and 18...". This clarifies to learners which assertions were preconditions and which ones were post-conditions
1 parent 4f56886 commit f20d0fd

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

_episodes/08-defensive.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ def normalize_rectangle(rect):
131131
~~~
132132
{: .python}
133133

134-
The preconditions on lines 2, 4, and 5 catch invalid inputs:
134+
The preconditions on lines 3, 5, and 6 catch invalid inputs:
135135

136136
~~~
137137
print(normalize_rectangle( (0.0, 1.0, 2.0) )) # missing the fourth coordinate
@@ -177,7 +177,7 @@ AssertionError: Invalid X coordinates
177177
~~~
178178
{: .error}
179179

180-
The post-conditions help us catch bugs by telling us when our calculations cannot have been correct.
180+
The post-conditions on lines 17 and 18 help us catch bugs by telling us when our calculations cannot have been correct.
181181
For example,
182182
if we normalize a rectangle that is taller than it is wide everything seems OK:
183183

@@ -217,7 +217,7 @@ AssertionError: Calculated upper Y coordinate invalid
217217
{: .error}
218218

219219
Re-reading our function,
220-
we realize that line 10 should divide `dy` by `dx` rather than `dx` by `dy`.
220+
we realize that line 11 should divide `dy` by `dx` rather than `dx` by `dy`.
221221
(You can display line numbers by typing Ctrl-M, then L.)
222222
If we had left out the assertion at the end of the function,
223223
we would have created and returned something that had the right shape as a valid answer,

0 commit comments

Comments
 (0)