Stats

16 Contributors: 1
2016-08-03
Licensed under: CC-BY-SA

Not affiliated with Stack Overflow
Rip Tutorial: info@zzzprojects.com

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