Inherit from the Standard Library

As always, Google manages to fail for even the stupidest programming queries because it ignores special characters ” < ", etc... So, it turns out that I've never actually inherited from the standard library before. Time to get some stupid errors that make me look like a fool on Ruby-talk when I ask about them. Specifically: ~/ruby/lib/foohelper.rb:432:NameError:
uninitialized constant FooHelper::Logger


irb(main):001:0> module Foo
irb(main):002:1> class Bar < Logger irb(main):003:2> def self.baz(t); p t; end
irb(main):004:2> end; end
NameError: uninitialized constant Foo::Logger
from (irb):2
irb(main):005:0> module Foo
irb(main):006:1> require 'logger'
irb(main):007:1> class Bar < Logger irb(main):008:2> def self.baz(t); p t; end
irb(main):009:2> end; end
=> nil
irb(main):010:0> Foo::Bar.baz("How to inherit from the stdlib")
"How to inherit from the stdlib"
=> nil

irb to the rescue and I didn’t even post to Ruby-talk, but missing ‘require’ made me feel pretty dumb…

Comments are closed.