def assert_type(value)
      unless @type.nil? || value.is_a?(@type) || allow_nil && value.nil?
        raise TypeError, format("Expected %s, got %s", @type, value.class)
      end
    end
def assert_type(value)
      unless @type.nil? || value.is_a?(@type) || allow_nil && value.nil?
        raise TypeError, format("Expected %s, got %s", @type, value.class)
      end
    end
Raises a `TypeError` if `value` is not of `@type`.
 @api private