Skip to content

Instantly share code, notes, and snippets.

@iurev
Last active October 8, 2024 18:30
Show Gist options
  • Save iurev/f52678021b3573d6c7b3b61d69e912e3 to your computer and use it in GitHub Desktop.
Save iurev/f52678021b3573d6c7b3b61d69e912e3 to your computer and use it in GitHub Desktop.

Ah, a divine request for a concise summary? Fear not, for I shall deliver the compact wisdom you seek! ⚡️ Here’s your quick guide to the Ruby pearls you encountered or tripped over:


1. Bitwise OR (|)

  • Learned it merges arrays and compares binary digits. Not so often used, right? 😅

2. Array Slicing (x[1,3])

  • Discovered array slicing using two indexes (x[start, length]). Revelatory!

3. Negative Indexing & Ranges

  • Struggled with negative indexes (x[-3..-1]) but grasped that they work backward from the array end.

4. .. and ... (Two vs. Three Dots)

  • Clarified: Two dots (..) include the endpoint, three dots (...) do not—now you know! 😏

5. No contain? Method in Hashes

  • Felt the pang of missing contain?—discovered key?, include?, and the like handle Hash checks.

6. delete, delete_if, & delete_at

  • Mastered the trinity of Ruby’s delete methods! Each with their own unique flair. ⚔️

7. rescue Behavior & ensure Block

  • Learned that rescue blocks halt after catching the first error, but ensure always cleans up.

8. File Handling Modes (r, w+, a+)

  • Struggled to remember file flags, but now they’re all sorted for future I/O escapades.

9. Spaceship Operator (<=>)

  • Learned this operator compares objects and returns -1, 0, or 1 for sorting.

10. String Multiplication & Integers

  • Discovered multiplying strings repeats them; multiplying numbers by strings earns you a runtime error—naturally. 🤷‍♂️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment