It would be nice if Ruby had a syntax for memoizing a method that would handle the nil/false case and update the shape at init time.
If Ruby supported something like
class A
def @instance_variable
def self.@singleton_class_instance_variable
def @@class_variable
end
as a way to pre-declare the object shape at class load time, it would be an obvious place to also let type checkers declare the types of these instance variables.(Not saying that this specific syntax is ideal, but rather just that having some syntax for declaring instance variables at load time, not method run time, would solve both the "predetermined object shape" and "predetermined ivar types" problems.)