Skip to content

Instantly share code, notes, and snippets.

@CraigCottingham

CraigCottingham/base.rb

Last active Dec 11, 2015
Embed
What would you like to do?
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