Skip to content

Instantly share code, notes, and snippets.

@megstang
Created August 19, 2020 03:58
Show Gist options
  • Save megstang/1c51aa919cc082e9c3ceb1114cc57747 to your computer and use it in GitHub Desktop.
Save megstang/1c51aa919cc082e9c3ceb1114cc57747 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