Test
October 28, 2020•238 words
"There are two ways of doing something: right and again."
Tally of Errors:
- Logic:
- Spelling:
- Syntax: vs.
- Actualy Learning Something New:
- I forgot to save my case statement into a variable when I refactored it from the original if/else statement (where the result was saved into a result variable). Due to this, my line that displays the result through string interpolation threw a NameError because I was interpolating a variable that no longer existed in my refactored code.
- this is a syntax error
- avoidable
- Still have issues with calling methods:
def valid?(n)
n.to_i != 0
end
"1".valid?
valid?("1")
=> true
Exploration:
"1".valid?
- I am calling the
.valid?
method on the string ojbect.
VS.
valid?("1")
- I am passing into the
.valid?
method an argument of"1"
Still uncertain as to the difference here?
- Logic Error:
I tried to use a break
in a method that was refactoring the conditional logic used to determine whether the loop should continue loop.
My error was moving all the code into the method without thinking carefully about where my break
should be to maintain the control flow. It should be in the loop, not inside the method. This is because the method extracts the conditional logic that if fulfiled will break
the loop: it comes AFTER the break
.
- logic error
- avoidable