Guest User

Untitled

a guest
Jan 18th, 2018
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.45 KB | None | 0 0
  1. 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
  2. use "<" to inherit from another class
  3. keyboard shortcuts: cmd - shift - v pastes the information and keeps indentation, cmd - ctrl - arrow to move lines around
  4. can use +=, *=, or -= to simplify (value = value + x) to (value += x)
  5. 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.
  6. if you use super() and specify arguments, it will override whatever the default arguments you were going to pass in are.
  7. I.E. passing in super(first_name: "Nathan") will override any other arguments I defined when creating that instance
  8. 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.
  9. 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|
  10. will loop through each time starting with i = 0 and then second loop will be i = 1 for as many items are in values.
  11.  
  12. Also learned about class variables denoted with 2 @'s a.k.a @@count. @count is an instance variable
  13. $count denotes a global variable
  14. COUNT denotes a constant which doesn't change throughout the code
  15. 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