Wednesday, May 9, 2012

Get input from console in Ruby

You can use the STDIN to get the input from console(shell/cmd/commandline).

to get a single character from the user.
chr = STDIN.getc

This is useful to implement something like "Press Enter to exit program." kind of things.

you can use gets, readline, etc with the STDIN.

FYI: for writing output to the screen, you need to use STDOUT.

No comments:

Get function name programaticaly - Python

This little piece of code will help you to get the function name programatically. This is very helpful when you are implementing the debug...