From: Chris Kottom Date: 2011-03-26T05:53:19+09:00 Subject: Re: How to "find" new lines --20cf3005126c492372049f54bf91 Content-Type: text/plain; charset=UTF-8 I assume that txtArray is a String in spite of the name. If so, then your comparison is probably easiest done through regular expressions: if txtArray =~ /\n/ ... end On Fri, Mar 25, 2011 at 9:28 PM, Damir Sigur wrote: > I am new to ruby, and was trying to make a small code which would check > if a string has only new line character in it. At the end I found that a > method "inspect" will do the trick. > > Is that the only way to handle new line characters? > > How about other special characters, if there is a need to search for > them in a text? > > Code that didn't work: > > if txtArray[i] <=> "\n" then > > Code that worked: > > if txtArray[i].inspect <=> "\n" then > > Thanks for all comments. > > -- > Posted via http://www.ruby-forum.com/. > > --20cf3005126c492372049f54bf91--