Skip to content

Instantly share code, notes, and snippets.

@krisalyssa
Last active December 11, 2015 03:48
Show Gist options
  • Save krisalyssa/4540262 to your computer and use it in GitHub Desktop.
Save krisalyssa/4540262 to your computer and use it in GitHub Desktop.
Just how wrong is this? It works, but it feels dirty to call a method on the child class when it's not fully initialized yet.
class Base
def initialize
@var = []
init_var
end
def size_of_var
@var.size
end
end
o = Sub.new
o.size_of_var # should return 4
class Sub < Base
def init_var
@var = %w( some list of elements )
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment