Skip to content

Instantly share code, notes, and snippets.

@j0ni
Last active May 5, 2016 16:15
Show Gist options
  • Save j0ni/0351ca78b90aca8a4504418a14d325b0 to your computer and use it in GitHub Desktop.
Save j0ni/0351ca78b90aca8a4504418a14d325b0 to your computer and use it in GitHub Desktop.
class Table
class << self
def say_goodbye
puts "goodbye"
end
def count
@@count ||= 0
end
def increment_table_count
Table.say_hello
@@count = count + 1
end
def decrement_table_count
self.say_goodbye
@@count -= 1
end
end
def self.say_hello
puts "hello"
end
def initialize
Table.increment_table_count
end
def self.finalize(table)
proc { Table.decrement_table_count }
end
end
puts Table.count
t1 = Table.new
puts Table.count
t1 = nil
GC.start
puts Table.count
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment