pub unsafe extern "C" fn rb_obj_instance_exec(
argc: c_int,
argv: *const VALUE,
recv: VALUE,
) -> VALUEExpand description
Executes the given block within the context of the receiver. In order to
set the context, the variable self is set to recv while the code is
executing, giving the code access to recv’s instance variables. Arguments
are passed as block parameters.
@param[in] argc Number of objects in argv
@param[in] argv Arbitrary parameters to be passed to the block.
@param[in] recv The object in question.
@return What was evaluated.
@note Don’t confuse this with rb_obj_instance_eval. The key
difference is whether you can pass arbitrary parameters to the
block, like this:
class Foo
def initialize
@foo = 5
end
end
Foo.new.instance_exec(7) {|i| @foo + i } # => 12Generated by rb-sys for Ruby mri-x86_64-linux-gnu-3.2.3