Created
March 27, 2012 17:05
-
-
Save wapcaplet/2218003 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# When `person` is initialized, even if it's only set to nil, then the | |
# value is shared both inside and outside the block: | |
person = nil | |
Neo4j::Transaction.run do |tx| | |
person = Person.new(params) | |
puts "Inside block, person: #{person}" | |
end | |
puts "Outside block, person: #{person}" | |
# output: | |
# Inside block, person: #<Sherman::Core::Person:0x30fffd2c> | |
# Outside block, person: #<Sherman::Core::Person:0x30fffd2c> | |
# But when `person` is not initialized until we get to inside the block, | |
# then `person` is unavailable outside the block: | |
#person = nil # person not initialized | |
Neo4j::Transaction.run do |tx| | |
person = Person.new(params) | |
puts "Inside block, person: #{person}" | |
end | |
puts "Outside block, person: #{person}" | |
# output: | |
# Inside block, person: #<Sherman::Core::Person:0x1d8f6445> | |
# (exception occurs) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment