require
、load
、File.read+eval
で、それぞれのコンテキストがどう変わるのかを確認するためのgist
ruby main.rb
main.rb:
self.class: Class
self.hash: -950369771375252526
respond_to?(:hello): true
/.../be_require.rb:
self.class: Object
self.hash: -2118450235971363218
respond_to?(:hello): false
/.../be_load.rb:
self.class: Object
self.hash: -2118450235971363218
respond_to?(:hello): false
(eval):
self.class: Class
self.hash: -950369771375252526
respond_to?(:hello): true