Nil - Nothing is Easy, Is It?
summary
Nil causes expensive runtime errors and the talk gives concrete fixes: use the safe navigation operator (&.) (Ruby 2.3), prefer Array.wrap and .compact for collections, use .dig for nested hashes, avoid blanket rescue clauses, and consider result/option types (resad, dry-monads) or the Null Object pattern to replace nil at the source. ActiveSupport’s blank/present and conditional assignment are discussed, plus warnings about false vs nil and surprising language behaviors (compact on Enumerable added in Ruby 3.1).
AI-written summary · about
chapters (21)
- 0:00Introduction
- 1:04Why this talk matters
- 2:10The billion-dollar mistake
- 3:57Nil in Ruby
- 5:41Nil behavior in Ruby
- 7:10Safe nil checks
- 10:41Nil assignment
- 12:28NoMethodError with nil
- 14:34Why nil causes problems
- 17:23Handling nil safely
- 20:34Safe navigation operator
- 22:42Replace nil with values
- 24:50Array.wrap to avoid nil
- 25:51Nested structures with dig
- 26:54Result types for failures
- 29:51Null object pattern
- 33:02Special case pattern
- 36:39Eliminating conditionals
- 38:25Other billion-dollar mistakes
- 40:12Further reading
- 40:53Q&A








