From: ni ed Date: 2012-07-10T23:30:56+09:00 Subject: How to get the code block to be executed from a file? Hi, When working with method blocks in ruby, how to get the code block to be executed from a file? In the below example, I want to read the 2 lines in the block (line1, line2) from a file instead of directly placing them as mentioned below. The following works fine, but when passing these to lines (line1, line2) by reading from a file, ".call" doesn't seem to be successful; no output; It doesn't throw any exceptions either. def method_execution(&method_block) begin method_block.call rescue => msg fail("Test Failed : " + msg) end end def test method_execution{ s = 5 + 4 # line 1 puts s # line 2 } end Any suggestions are appreciated. Thank you.. -- Posted via http://www.ruby-forum.com/.