How to correctly define a block for instance_exec #2039
Unanswered
aaronmallen
asked this question in
Q&A
Replies: 1 comment 1 reply
-
Seems like you can specify class ParameterBuilder
def define: (String | Symbol parameter_name) ?{ (?) [self: self] -> void } -> self
end
class BaseConstraint
attr_reader self.parameter_builder: ParameterBuilder
def self.parameter: (String | Symbol parameter_name) ?{ (ParameterBuilder) [self: ParameterBuilder] -> ParameterBuilder } -> void
end class ParameterBuilder
def define(parameter_name, &block)
instance_exec(&block) if block
self
end
end
class BaseConstraint
def self.parameter(parameter_name, &)
parameter_builder.define(parameter_name, &)
end
end Steep doesn't infer based on |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
What is the correct way to define the signature for an
instance_exec
block?Beta Was this translation helpful? Give feedback.
All reactions