From: "Florian Groß" Date: 2005-11-07T11:01:26+09:00 Subject: Re: Lazy fun: Make unary minus silence stderr for backticks Sam Stephenson wrote: > I was reading about mentalguy's lazy.rb and thought it'd be fun to use > lazy evaluation as a vehicle for adding new syntactic sugar to Ruby. > Here's one such example, which lets you prefix backticks with a unary > minus to silence stderr: > > | % irb -r lazy_backtick > | irb(main):001:0> `hello` > | /opt/local/lib/ruby/1.8/irb/workspace.rb:81: command not found: hello > | => "" > | irb(main):002:0> -`hello` > | => "" Nice hack, but here's a case that doesn't work and for that I don't have a fix: String.new(`echo foo`) Which returns "" for me. I guess you are better off not inheriting from String and letting the String === test fail. Nowadays it's all about duck typing, anyway.