Lesson 1.9: Good vs Bad Questions Flashcards
1
Q
Can I access a constant that’s defined outside a method? - why is this a bad question
A
The reason this question is bad is because it’s easily testable. The word “bad” may be a little strong, but we want to encourage you to try things out yourself. Create a new .rb file and give it a shot:
2
Q
Why is it that a constant is accessible from a method, but a local variable isn’t? Here’s an example:
A
A better question would be to observe this behavior, and note how it differs from local variable scope rules, and ask why. This is an example of a good question.