From: Tom Reilly Date: 2013-03-30T09:25:53+09:00 Subject: Re: Nil or enter with no input Phil H. wrote: > How can I tell if someone has enter nothing in a gets prompt, they only > press enter. I though maybe it was nil, but that doesn't seem to work. I > though this was going to work nicely, but doesn't. > > # Building and sorting an array. > > array = [] > word = 'foo' > > while word != nil > puts 'Enter a word' > word = gets > array.push word > end > > puts array.sort > Using enter even with no other character will return a \r\n or \n depending upon your operating system Tom Reilly