Null Errors :: 0x10

Back to the wonderful world of "Exactly right except for a single keystroke" we go.

If it was written correctly, this program would output a random number between 5 and 500. But due to a typo, it'll fail to behave as expected.

@running_total = 0

5.times { @running_total += rand(1..100) }

p @running_t0tal

(1) If the code was run as-is, what will the output be?

# [ANSWER 1] #

 nil

(2) If the same typo was present but the running total was stored in a local variable instead of an instance variable, would you get the same result, or would the program behavior change?

# [ANSWER 2] #

The program would crash (raising a NameError) with the message:
"undefined local variable or method 'running_t0tal' for main"

The field notes for this exercise are not included in the free sample, but will be provided in the paid version of this guidebook.

You can preorder now to be among the first to gain access when it is released.