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?
—discoveredkey?
,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, butensure
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
, or1
for sorting.
10. String Multiplication & Integers
- Discovered multiplying strings repeats them; multiplying numbers by strings earns you a runtime error—naturally. 🤷♂️