Step 3 / Select topic Ruby Easy
What this bank covers
- Integer vs Float division in Ruby
- `and`/`or` bind looser than `=`
- Integer#gcd
- Math.sqrt always returns a Float
- Summing a Range
- Integer.sqrt
- map transforms every element
- tally counts occurrences in first-seen order
- select keeps the matching elements
- take_while stops at the first failure
- sort_by orders by a computed key
- Range#step walks the range in increments
- each_with_index yields element then index
- Maximizing with max_by
- minmax returns both extremes
- min_by for the closest value
- Taking the top N with max(n)
- sort.first versus min
- Memoizing with ||=
- String keys vs Symbol keys
- Strings are shared by reference
- Strings compare character by character
- String#% as a format operator
- Numeric == compares mathematical value
- Array as a stack: push and pop
- Array as a queue: shift takes the front element
- Hash#fetch with a default value
- Hash#dig through nested hashes and arrays
- Set discards duplicate values
- Hash keys come back in insertion order
- Default parameter values
- Methods do not see surrounding locals
- retry restarts the begin body
- next and break inside a while loop
- rescue matches subclasses of the named class
- Thread#value returns the block's result
- Thread::Queue is FIFO
- Fiber.yield and resume
- Thread.current vs Thread.main
- Queue#pop, #size and #empty?
- String#swapcase
- String#split keeps interior empty fields
- start_with? is case-sensitive
- String#strip
- String#gsub replaces all matches
- String#sub replaces one match
- Substring by start and length
- String#+ concatenates
- String#count
- Keyword arguments with defaults
- block_given? and yield
- Lambdas close over local variables
- rescue and ensure order in a method body
- begin/rescue/else/ensure
- Only nil and false are falsy in Ruby
- Floats cannot represent 0.1 exactly
- ensure runs even on an explicit return
- A bare raise re-raises the current exception
- Exponentiation is right-associative
- Integer vs float division
- The spaceship operator
- && returns an operand, not a boolean
- Integer#divmod
- Comparable#clamp
- Modulo with a negative dividend
- String#capitalize
- Enumerable#each_slice
- Array#zip with a shorter argument
- Enumerator::Lazy
- Array#flatten with a depth limit
- Array#rotate
- Array#insert with multiple values
- Keyword arguments with default values
- Block-local variables declared after a semicolon
- Default argument values can reference earlier parameters
- case/when with ranges
- ensure runs with or without an exception
- The class of a rescued exception
- Collecting results from several threads
- Guarding a shared counter with a Mutex
- Fiber resume values and alive?
- Closing a Thread::Queue
- Hash.new(0) for counters
- Range#bsearch in find-minimum mode
- find stops at the first match
- Set vs Array membership tests
- Assigning past the end of an Array
- Hash defaults do not create keys
- <=> returns nil for incomparable operands
- Array#uniq keeps first occurrences
- Thread state after join