mod.class_exec(arg...) {|var...| block } â obj
Instance Public methods
Evaluates the given block in the context of the class/module. The method defined in the block will belong to the receiver.
1 2 3 4 5 6 | class Thing end Thing.class_exec{ def hello() "Hello there!" end } puts Thing. new .hello() |
produces:
1 | Hello there! |
Please login to continue.