Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →
instance method
RubyVM::InstructionSequence#eval
() -> untyped
iseq.eval → obj
iseq.c
View on GitHub ↗
static VALUE
iseqw_eval(VALUE self)
{
const rb_iseq_t *iseq = iseqw_check(self);
if (0 == ISEQ_BODY(iseq)->iseq_size) {
rb_raise(rb_eTypeError, "attempt to evaluate dummy InstructionSequence");
}
return rb_iseq_eval(iseq, rb_current_box());
}
Evaluates the instruction sequence and returns the result.
Example
RubyVM::InstructionSequence.compile("1 + 2").eval #=> 3