Step 3 / Select topic Ruby Hard
What this bank covers
- Module comparison operators (<, <=, >, <=>)
- Ruby equality: ==, eql?, === and <=> across numeric types
- Spaceship operator and incomparable types
- Floored division, modulo, and remainder
- Integer exponentiation with a negative exponent
- Assignment binds tighter than `or`
- Precedence and associativity of **
- Numeric coercion across Integer, Rational, and Float
- Integer#divmod with a negative dividend
- Exact Rational addition and normalization
- Integer.sqrt gives the exact floor of a square root
- Array#sum uses compensated summation for Floats
- NaN equality versus Array#include?
- Integer#round with negative digits and the half: option
- Integer#to_s and String#to_i with explicit bases
- truncate, floor, and round on a negative half
- Integer#pow with a modulus
- Deduplicated frozen strings with -@
- String slicing at and past the end
- String#succ carry rules
- gsub with a hash replacement
- split limits, awk mode, and empty separators
- << mutates, += rebinds
- dup, clone, and +@ on a frozen string
- String#% format directives
- String#tr with character ranges
- chunk_while groups consecutive runs
- each_with_object discards the block's return value
- Lazy chains pull only what is needed
- zip with a block returns nil
- peek does not advance an Enumerator
- group_by keys follow first-seen order
- flat_map flattens exactly one level
- Counting block invocations in a lazy filter
- cycle without a block returns an endless Enumerator
- Enumerable builds on a single each method
- Hash.new with a mutable default object
- Array.new default value vs block form
- Mutating a hash key requires rehash
- Hash#[]= duplicates and freezes String keys
- Struct value semantics as hash keys
- Deleting from an array while iterating it
- Hash insertion order after delete and reassignment
- Shallow dup vs Marshal deep copy
- dup vs clone and frozen state
- Set equality and hashing ignore insertion order
- A nested def defines a method on the enclosing class
- Block-local variable declarations
- Local variables are created at parse time
- Default arguments see earlier parameters
- `return` inside a non-lambda proc
- define_method closes over locals, `def` does not
- Hash literals are positional in Ruby 3
- Bindings know every local of the scope
- `for` does not create a new scope, blocks do
- Orphaned proc with `return`
- Explicit return inside ensure
- retry restarts the begin body
- Bare rescue only catches StandardError
- throw unwinds to catch with a value
- next supplies a block's value
- break returns from the yielding method
- Kernel#loop rescues StopIteration
- An exception from ensure replaces the original
- Automatic exception cause chaining
- Exceptions raised in an else clause skip their own rescue
- Fiber-local vs thread-local variables
- Popping from a closed Queue
- Thread#status after termination
- Values passed through Fiber.yield and resume
- Mutex#synchronize, owned? and locked?
- Thread#join return value with a timeout
- ConditionVariable#wait releases the mutex
- SizedQueue blocks producers until space frees up
- Thread#kill still unwinds ensure clauses
- Memoization with ||= and falsy results
- Array#sum uses compensated summation
- << mutates in place, += reallocates
- Lazy enumerators pull only what is needed
- sort_by is a Schwartzian transform
- bsearch is logarithmic in the array length
- Hash default proc as a memo table
- inject threads the block's return value, each_with_object does not
- String#-@ deduplicates, String#+@ unfreezes
- The `||=` memoization hole for falsy values
- Module#prepend inserts the module before the class
- Find patterns match the leftmost occurrence
- compare_by_identity keys on object identity
- Protected methods and respond_to?
- Currying a non-lambda proc
- Lexical scope wins over inheritance for constants
- Comparable and a nil spaceship result
- dup versus clone and singleton methods
- Float#to_r versus Float#rationalize
- squeeze, delete, and count share one character-set notation
- Thread status after an uncaught exception
- Endianness modifiers in pack and unpack
- Singleton class ancestry with extend and prepend
- Bitwise operators on negative Integers
- Value of an assignment expression with a custom []=