Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
comp.lang.ruby
Non-newline gets
Michael Boutros
12/21/2008 6:59:00 AM
Hello,
I'm writing a CLI and I want to get some additional information after I
first run the script, namely the username. Take a look.
-- code
puts "Welcome. Enter username: "
username = gets.strip
-- /code
That works fine, but the issue is that it takes the username on a new
line, like so:
$ ruby script.rb
Welcome. Enter username:
michaelboutros
How can I make it so that the username can be entered on the same line?
Thanks,
Michael Boutros
--
Posted via
http://www.ruby-...
.
1 Answer
Yaser Sulaiman
12/21/2008 7:14:00 AM
0
[Note: parts of this message were removed to make it a legal post.]
Don't use puts, use print instead.
print "Welcome. Enter username: "
Regards,
Yaser Sulaiman
On Sun, Dec 21, 2008 at 9:58 AM, Michael Boutros <me@michaelboutros.com>wrote:
> Hello,
>
> I'm writing a CLI and I want to get some additional information after I
> first run the script, namely the username. Take a look.
>
> -- code
> puts "Welcome. Enter username: "
> username = gets.strip
> -- /code
>
> That works fine, but the issue is that it takes the username on a new
> line, like so:
>
> $ ruby script.rb
> Welcome. Enter username:
> michaelboutros
>
> How can I make it so that the username can be entered on the same line?
>
> Thanks,
> Michael Boutros
> --
> Posted via
http://www.ruby-...
.
>
>
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
Non-newline gets
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password