Stats

16 Contributors: 1 Wednesday, August 3, 2016
Licensed under: CC-BY-SA
Not affiliated with Stack Overflow
Rip Tutorial: riptutorial@gmail.com
Roadmap: roadmap
Download eBook

instance_eval

Download ruby eBook

Syntax

  • object.instance_eval 'code'
  • object.instance_eval 'code', 'filename'
  • object.instance_eval 'code', 'filename', 'line number'
  • object.instance_eval { code }
  • object.instance_eval { |receiver| code }

Parameters

ParameterDetails
stringContains the Ruby source code to be evaluated.
filenameFile name to use for error reporting.
linenoLine number to use for error reporting.
blockThe block of code to be evaluated.
objThe receiver is passed to the block as its only argument.

Related Examples