From: "Mauricio Fernández" Date: 2003-06-24T02:30:16+09:00 Subject: Re: Runtime interpretation On Tue, Jun 24, 2003 at 02:21:45AM +0900, Orion Hunter wrote: > I want to know how to interpret something from a string, so as to be used > directly by the interpreter at runtime. A simplified example: > > $> ruby myprogram.rb > Enter object information:> Array.new(4) > object created:> [nil, nil, nil, nil] > Enter object information:> Hash.new() > object created:> {} > Enter object information:> MyObject.new(2,4,6) > etc., etc. You mean this? batsman@tux-chan:/tmp/ruby-1.8.0$ expand -t 2 /tmp/az.rb require 'readline' loop do line = Readline.readline("Enter object information:> ", true) obj = eval line puts "object created:> #{obj.inspect}" end batsman@tux-chan:/tmp/ruby-1.8.0$ ruby /tmp/az.rb Enter object information:> Array.new(4) object created:> [nil, nil, nil, nil] Enter object information:> Hash.new() object created:> {} -- _ _ | |__ __ _| |_ ___ _ __ ___ __ _ _ __ | '_ \ / _` | __/ __| '_ ` _ \ / _` | '_ \ | |_) | (_| | |_\__ \ | | | | | (_| | | | | |_.__/ \__,_|\__|___/_| |_| |_|\__,_|_| |_| Running Debian GNU/Linux Sid (unstable) batsman dot geo at yahoo dot com Software is like sex; it's better when it's free. -- Linus Torvalds