$ ruby -v
ruby 1.8.7 (2009-06-12 patchlevel 174) [i686-darwin10.2.0]
Step 1
irb(main):002:0> require ‘ostruct’
=> true
Step 2
irb(main):005:0* Object.send(:remove_const, :OpenStruct)
=> OpenStruct
Step 3
ensure that OpenStruct is truly removed
irb(main):006:0> Object.send(:remove_const, :OpenStruct)
NameError: constant Object::OpenStruct not defined
from (irb):6:in remove_const' from (irb):6:in
send’
from (irb):6
Step 4
irb(main):007:0> require ‘ostruct’
=> false
Step 5
irb(main):009:0> OpenStruct.new
NameError: uninitialized constant OpenStruct
from (irb):9
Questions:
-
OpenStuct constant was removed in step2. Why the return value of
require in step 4 is “false” ? -
require was done in step 4 then why OpenStruct is not available and
why did step 5 fail ?