Skip to content

Instantly share code, notes, and snippets.

@CraigCottingham
Last active December 11, 2015 03:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CraigCottingham/4540262 to your computer and use it in GitHub Desktop.
Save CraigCottingham/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