Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- don't use DRY code (don't repeat yourself code). We can use inheritance with other classes so that code doesn't have to repeat
- use "<" to inherit from another class
- keyboard shortcuts: cmd - shift - v pastes the information and keeps indentation, cmd - ctrl - arrow to move lines around
- can use +=, *=, or -= to simplify (value = value + x) to (value += x)
- using "super" in a method, we can pull in all of the original code from the super class's method, so we don't need to copy and paste all of that code again. i.e. the initialize method.
- if you use super() and specify arguments, it will override whatever the default arguments you were going to pass in are.
- I.E. passing in super(first_name: "Nathan") will override any other arguments I defined when creating that instance
- If you call the same method in a subclass of that in a super class, it will overwrite the method from the super class and redefine it.
- In a times loop, you can use a block that defaults to start at 0 and increments by 1 through each loop. for example, values.times do |i|
- will loop through each time starting with i = 0 and then second loop will be i = 1 for as many items are in values.
- Also learned about class variables denoted with 2 @'s a.k.a @@count. @count is an instance variable
- $count denotes a global variable
- COUNT denotes a constant which doesn't change throughout the code
- also learned about the Private methods. Use this to create methods that can only be called within the class itself.
Add Comment
Please, Sign In to add comment