Skip to content

Instantly share code, notes, and snippets.

@ajpulzone
Forked from megstang/global_scope_examples.md
Created August 25, 2022 16:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ajpulzone/eb75b80e9c039d324fef4a5efe30dfa9 to your computer and use it in GitHub Desktop.
Save ajpulzone/eb75b80e9c039d324fef4a5efe30dfa9 to your computer and use it in GitHub Desktop.
Global Scope Examples

Example 1

x = 10
puts x
puts y

Example 2

x = 10
puts x
puts y
y = 20

Example 3

x = 10
def say_hello
  puts "Hello World!"
end
puts x

Example 4

def print_variable
  x = 4
  puts x
end

x = 2
print_variable

Example 5

def print_variable
  x = 4
end

x = 2
print_variable
puts x
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment