Gets, etc (was RE: Newbie Questions)

fr Azalar:

Makes sense now that i’ve seen what is happening behind the scenes.

I come from a Java background but didn’t think to test if it

was adding carriage returns to the end of the string.

that is a faq but you may have a point.
others would argue that “hey, i have to enter a newline otherwise you
wont accept it, and now you’re telling me to chop it off?!”.
maybe, we can we have #gets2 or #input (for lack of better a word) that
automatically chops newline if there is one, orthogonal to #puts putting
one if there is none.

kind regards -botp

Hi,

At Fri, 23 Jun 2006 10:06:38 +0900,
Peña, Botp [email protected] wrote in [ruby-talk:198616]:

fr Azalar:

Makes sense now that i’ve seen what is happening behind the scenes.

I come from a Java background but didn’t think to test if it

was adding carriage returns to the end of the string.

that is a faq but you may have a point.
others would argue that “hey, i have to enter a newline
otherwise you wont accept it, and now you’re telling me to
chop it off?!”.

Double Ctrl-D sends a text without a newline.

maybe, we can we have #gets2 or #input (for lack of better a
word) that automatically chops newline if there is one,
orthogonal to #puts putting one if there is none.

a) use readline to input
b) use Regexp to match

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs