How to make a command-line string code block argument become a real block of code inside a script

If a exec
Ruby myprog.rb ‘{ print " hi body "}’

How to convert that string to a real block to pass it to a method

def what_u_ask &b
yield
End

what_u_ask ARGV[0]

This does not work for me. Thank you.

On 07/02/12 08:22, gabe gabriellini wrote:

This does not work for me. Thank you.

This should work.

def what_u_ask &b
yield
end

eval “what_u_ask #{ARGV[0]}”

Sam

Solved !

Thanks Sam

eval “what_u_ask #{ARGV[0]}”

Works Great.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs