Skip to content

Instantly share code, notes, and snippets.

@jlindley
Created January 11, 2011 20:41
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jlindley/775089 to your computer and use it in GitHub Desktop.
Save jlindley/775089 to your computer and use it in GitHub Desktop.
module Bar
def self.anon_struct
s = Struct.new(:foo, :bar, :baz)
oid = s.object_id
s = nil
oid
end
end
GC.start
oid = Bar.anon_struct
puts "Object id #{oid}:"
puts ObjectSpace._id2ref(oid).inspect
#
# OUTPUTS
#
# Object id 2151904380:
# <Class:0x0000010086e8f8>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment