Last active
May 5, 2016 16:15
-
-
Save j0ni/0351ca78b90aca8a4504418a14d325b0 to your computer and use it in GitHub Desktop.
This file contains 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
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