From: James Edward Gray II Date: 2007-03-27T00:24:56+09:00 Subject: Re: gets gets On Mar 26, 2007, at 3:17 AM, John Joyce wrote: > I'm a little surprised at this. > In irb, I tried puts gets gets. > Why? I don't know. > but basically, gets gets, seems to almost act like a heredoc! > myString = gets gets > puts myString It's not surprising at all. First, let's insert the parentheses so we can see it as Ruby does: puts(gets(gets())) Now we see that the right-most gets() call must be resolved first. Assuming you enter the String "END", that will be passed to the left- most gets() call as a parameter. The parameter to gets() is an input record divider, so it will read ahead until it encounters "END" instead of the traditional "\n". This is the heredoc-like behavior you are seeing. The result of the second gets() is then printed by puts(). Hope that explains what you are seeing. James Edward Gray II