last-input entered on command line

I

Ian M. Asaff

[Note: parts of this message were removed to make it a legal post.]

Hi Everyone,

I'm writing a console application to teach myself Ruby. The app displays a
task, eg "write a one-liner that returns [1,2,3,4]" and I write a ruby
statement that evaluates to the requested object.

for example:
write a one-liner that outputs [1, 2, 3, 4]
(1..4).inject([]) {|m,i| m << i}
good.

The problem I'm having is that, when I make a mistake or fat-finger
something, it's annoying to retype my code instead of just hitting the up
arrow (a la irb or any other command line utility I've used) and having my
previously entered statement appear. Then I can just fix my mistake and hit
"enter".

So, I'm trying to implement that functionality--hit the up arrow while the
program is running, and you get the last entered statement. I've googled and
stack-overflowed and have found some libraries I never new about (HighLine,
for example), but haven't been able to figure out how to make this work.

Any ideas?

Ian
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top