This or that? Similar methods & classes in Ruby && Rails
summary
Benchmarks on Ruby 3.3.0 compare many concrete alternatives: cover vs include shows cover ~2x faster on small ranges and massively faster on huge string ranges because include builds members; regular expression choices reveal regex side effects—match? is fastest and doesn’t set Perl globals, ~= and others do; NotImplementedError subclasses ScriptError so generic rescue doesn’t catch it; delegation can generate methods from lambdas but defining is ~146x slower and calling ~7x slower; eval-based tricks are ~281x slower; repo of tests and examples exists.
AI-written summary · about
chapters (8)
- 0:00Method vs class differences
- 5:51Range cover versus include methods
- 10:48Regex matching options
- 16:06NoMethodError vs NotImplementedError
- 18:33Monkey patching vs define_method
- 21:45Delegation in Ruby/Rails
- 28:49Calling methods creatively
- 35:07Q&A







