• Introduction
  • 1. Tricks
    • 1.1. Alphanumeric incrementing
    • 1.2. Associative arrays
    • 1.3. At exit method
    • 1.4. Autovivification
    • 1.5. Blocks can take blocks
    • 1.6. Bubbling up thread errors
    • 1.7. Case on ranges
    • 1.8. Count all objects
    • 1.9. Cycle
    • 1.10. Data
    • 1.11. Easiest database pstore
    • 1.12. Easiest database pstore yaml
    • 1.13. Enable garbage collector profiler
    • 1.14. Enable ruby warnings
    • 1.15. Fast memoization fibonacci
    • 1.16. Fetch data
    • 1.17. Get random data
    • 1.18. Head tail
    • 1.19. Inject
    • 1.20. Inspecting the source with script lines
    • 1.21. Iterating over specific types
    • 1.22. Lambda your own syntax
    • 1.23. Memoization
    • 1.24. Print formatted with debug
    • 1.25. Ruby debug flag
    • 1.26. Shortcut variable interpolation
    • 1.27. Single instance running
    • 1.28. Smalltalk conditionals
    • 1.29. Splat operator
    • 1.30. Stab operator
    • 1.31. Struct without assignment
    • 1.32. Super magic keyword
    • 1.33. Super magic keyword2
    • 1.34. Super magic keyword3
    • 1.35. Super magic keyword4
    • 1.36. Super magic keyword5
    • 1.37. Tail call
    • 1.38. Trigger irb as needed
    • 1.39. Unfreeze objects with fiddle
    • 1.40. Unused variable format
    • 1.41. Variables from a regex
    • 1.42. Zip
    • 1.43. Introspecting Block Parameters
  • 2. Idiomatic Ruby
    • 2.1. Each vs map
    • 2.2. Conditional assignment
    • 2.3. Combine operation over collections (enumerables)
    • 2.4. Array of Strings or Symbols
    • 2.5. Multiple Assignment
    • 2.6. Use Symbol to_proc
    • 2.7. Array Sample (enumerables)
    • 2.8. Use Fixnum#times
    • 2.9. Implicit Return
  • 3. Refactorings
    • 3.1. Conditionals when object is nil
    • 3.2. Switch case with Hashes
  • 4. Best Practices
    • 4.1. rescue => Exception e
  • Published with GitBook

Ruby Tricks, Idiomatic Ruby, Refactorings and Best Practices

Refactorings

  • Conditionals when object is nil
  • Switch case with Hashes