Skip to content

Instantly share code, notes, and snippets.

@justincampbell
Created May 12, 2014 18:59
Show Gist options
  • Save justincampbell/f0d33cc934ef3027cc36 to your computer and use it in GitHub Desktop.
Save justincampbell/f0d33cc934ef3027cc36 to your computer and use it in GitHub Desktop.
puts "Start parsing A"
require_relative 'b'
puts "Finish parsing A"
print "$foo_global_variable: "
p $foo_global_variable
print "@@foo_class_variable: "
p @@foo_class_variable
print "@foo_instance_variable: "
p @foo_instance_variable
print "foo_local_variable: "
p foo_local_variable
puts "Start parsing B"
$foo_global_variable = :bar
@@foo_class_variable = :bar
@foo_instance_variable = :bar
foo_local_variable = :bar
puts "Finish parsing B"
Start parsing A
Start parsing B
/Users/Justin/Dropbox/Code/playground/b.rb:4: warning: class variable access from toplevel
Finish parsing B
Finish parsing A
$foo_global_variable: :bar
a.rb:11: warning: class variable access from toplevel
@@foo_class_variable: :bar
@foo_instance_variable: :bar
foo_local_variable:
a.rb:17:in `<main>': undefined local variable or method `foo_local_variable' for main:Object (NameError)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment