Skip to content

Instantly share code, notes, and snippets.

@megstang
Created August 19, 2020 04:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save megstang/e239c2dd61704e404f7c323416a97db7 to your computer and use it in GitHub Desktop.
Save megstang/e239c2dd61704e404f7c323416a97db7 to your computer and use it in GitHub Desktop.
Method Scope Examples 6-9

Example 6

def print_variable
  x = 10
  puts x
end
print_variable
puts x

Example 7

def print_variable
  x = 4
  puts x
end

print_variable

Example 8

def print_variable
x = 4
puts x
end

x = 2
print_variable

Example 9

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