-
-
Save phluid61/70c75302512630642d36 to your computer and use it in GitHub Desktop.
ruby 'require' scope
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require_relative 'b' | |
Foo.new.foo | |
p ['Main in a.rb', $global, bar, Baz.qux] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Foo | |
def foo | |
require_relative 'c' | |
p ['Foo#foo in b.rb', $global, bar, Baz.qux] | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$global = 'global' | |
def bar | |
'bar' | |
end | |
class Baz | |
def self.qux | |
'Baz.qux' | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ ruby -v a.rb | |
ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-linux] | |
["Foo#foo in b.rb", "global", "bar", "Baz.qux"] | |
["Main in a.rb", "global", "bar", "Baz.qux"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment