Bertram Scharpf wrote:
> Hi Aldric,
> 
> Am Samstag, 31. Okt 2009, 01:46:10 +0900 schrieb Aldric Giacomoni:
>> Bertram Scharpf wrote:
>> > String#notempty?
>> 
>> Because some behavior is not there by default doesn't mean it's
>> a bias.
> 
> That's what I wanted to say: I am convinced it should be there by
> default. It's just a few lines of code. It's pure logic when you
> have Numeric#nonzero? and it's very useful to build default
> values:
> 
>   str.notempty? || "(none)"    # analoigous to SQL-coalesce()

It's trivial to build:

class String
  def notempty?
    empty? ? nil : self
  end
end

> 
> I guess it would be more useful than flip-flops or class variables.
> 
> Bertram

Best,
--
Marnen Laibow-Koser
http://www.marnen.org
marnen / marnen.org
-- 
Posted via http://www.ruby-forum.com/.