I am trying to do something a little unusual as a workaround to another problem. I would like to store ruby commands and execute them later.
I can store commands in variables ok but I can only print them to the screen, I played around with flatten to see could I somehow convert them to a usable form but it didn’t work.
Here is an example:
Command_Store = Array[puts "Hello World", my_first_array = array.new, puts "Hello World again"]
execute.Command_Store[0] => Hello World
execute.Command_Store[1] => my.first_array[]
execute.Command_Store[2] => Hello World again
Also you can use lambda for this kind of task:
UPDATE:
You can capture the variable
my_first_array, that’s what called the closure