last-input entered on command line

Discussion in 'Ruby' started by Ian M. Asaff, Nov 25, 2010.

  1. Ian M. Asaff

    Ian M. Asaff Guest

    [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
     
    Ian M. Asaff, Nov 25, 2010
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. TN Bella
    Replies:
    1
    Views:
    1,502
    TN Bella
    Jul 1, 2004
  2. Replies:
    0
    Views:
    109
  3. Paul Malbon
    Replies:
    2
    Views:
    182
    Paul Malbon
    Jan 20, 2006
  4. Luke Matuszewski
    Replies:
    8
    Views:
    129
    Luke Matuszewski
    Apr 22, 2006
  5. Sven
    Replies:
    0
    Views:
    93
Loading...

Share This Page