From: Paul McMahon Date: 2008-03-03T18:58:21+09:00 Subject: Re: Dealing with nil > With this, you can do > > irb(main):038:0> s=nil > => nil > irb(main):039:0> s.nil_safe(0) {length} > => 0 I don't really get your example... Why not just use s.to_s.length? In the more general case, why no just follow the pattern s.nil? ? 0 : s.length?