New to Ruby. Why does the command line pop up an then go awa

J

John Budd

When ever I run a code file .rb

The code,

puts "Hello"

I get the command prompt that flashes for a moment but does not stay up.


How do I fix this.
 
R

Raphael Clancy

This is not as correct as the other approaches, but you can also end
your code with "getc" then the program will pause until you press enter.
 
B

Bertram Scharpf

Hi John,

no harm meant indeed.

Am Dienstag, 10. Feb 2009, 08:32:14 +0900 schrieb Raphael Clancy:
This is not as correct as the other approaches, but you can also end
your code with "getc" then the program will pause until you press enter.
^^^^^

Unless you tweak "termios". What cannot be done on Windows...

Did ever anyone count the unnecessary and dulling questions
that arise by just running that wicked OS?

Sorry, sorry, sorry. I cannot resist posting the truism. A score
of times I refrained.

Bertram
 
7

7stud --

See edits:

Dan said:
If you want to [see] ruby console output[,] [then] run the script from a shell instead
of double clicking:

Essentially, your program does what you tell it: open a console window,
run the program, close the console window. Because running your program
takes only a microsecond, you see the console flash open and shut.
 
R

Raphael Clancy

Raphael said:
This is not as correct as the other approaches, but you can also end
your code with "getc" then the program will pause until you press enter.

Sigh... "getc" is sorta deprecated. Use "gets" or "STDIN.getc" if you
get a warning with "getc". (I guess it was even less correct than I
thought ;-D )
 

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

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top