Today I began by finishing up reviewing the flowchart/pseudo-code notes then I jumped into the calculator videos. Things seem more…shaped up in my mind when it comes to the overall structure about it. With that, my plan is to make a list of key points.
- If a variable is within an ‘if’ condition, it is available outside it.
- Variables within the loop/do processes need to be initialized outside it. Either do it on top of the loop itself or group them together with the rest of the variables.
- prompt(“message”) messages are awesome.
- Case statements are preferred over pure if/else statements when it comes to a user inputting an integer and there’s conditions for each.
- Extract methods to the top, since it reads it top to bottom.
- Rubocop is your friend. This will help you spot errors before you have to show them to anybody, so you have a chance to fix the code.
- Rememeber for division, if you divide by two whole numbers, you will get a whole number answer. To account for expected decimal answers, use .to_f.
- In Ruby, parentheses are optional.
That’s just some of them. Tomorrow I will continue with the calculator and move on to Variable Scope. Also, looking at how bland everything looks, pictures don’t seem like a bad idea. Will add those too, for proof/life to the posts.