This is a multi-part message in MIME format. ------ extPart_000_0057_01C129DE.F084AD30 Content-Type: text/plain; charset so-8859-1" Content-Transfer-Encoding: quoted-printable "Joshua Drake" <jd.nospam / commandprompt.com> wrote in message news:to335diag2p2ff / corp.supernews.com... > Hello, > > I am the author of the Programming in ruby on IBM Developworks. ... > I am getting ready to release the second article, but I want to get > some feedback from the ruby community first. I would like the second > article to be more ruby centric and will need some help. ... > while 1 ... > end Although this loops forever, as you intend, I would guess that it doesn't do so for the reason you think. Also it is very misleading code because people who are used to C would expect that 'while 0 ... end' would not loop at all, but in Ruby it is also an infinite loop. Ruby treats all values except false and nil as meaning 'true'. Secondly, Ruby provides an infinite loop method: 'loop {block}'. I would use this in preference to 'while true ... end'. Finally, please refactor your program before publishing the article. The code, as it is, is poorly structured and therefore not a good example of Ruby -- the script uses global variables for no reason, the methods are far too long, code structures are repeated instead of being abstracted as methods, and so on. Also, the program doesn't use any of Ruby's interesting features, such as creating domain specific iteration statements. I would suggest rewriting the example using these kind of idioms, otherwise all you are demonstrating is that Ruby has a different syntax to Perl. You could also demonstrate Ruby's open classes by defining your iterators as methods of the built-in File class, and demonstrate Ruby's singleton methods by adding methods to the STDIN object. E.g. the main loop should look something like this: File.open( address_file ) do |file| STDIN.each_address_input do |addr| file.write_address( addr ) end end The each_address_input method is a singleton method that reads addresses from the input stream until the user inputs END. The write_address method would write an address into the file in the standard format. ------ extPart_000_0057_01C129DE.F084AD30 Content-Type: text/html; charset so-8859-1" Content-Transfer-Encoding: quoted-printable <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML><HEAD> <META http-equiv=Content-Type content="text/html; charset=iso-8859-1"> <META content="MSHTML 5.50.4134.600" name=GENERATOR> <STYLE></STYLE> </HEAD> <BODY bgColor=#ffffff> <DIV><FONT face=Arial size=2> <DIV>"Joshua Drake" <<A href="mailto:jd.nospam / commandprompt.com">jd.nospam / commandprompt.com</A>> wrote in message <A href="news:to335diag2p2ff / corp.supernews.com">news:to335diag2p2ff / corp.supernews.com</A>...</DIV> <DIV>> Hello,<BR>> <BR>> I am the author of the Programming in ruby on IBM Developworks.<BR>...<BR>> I am getting ready to release the second article, but I want to get<BR>> some feedback from the ruby community first. I would like the second<BR>> article to be more ruby centric and will need some help.<BR>...</DIV> <DIV>> while 1</DIV> <DIV>...<BR>> end</DIV> <DIV><BR> </DIV> <DIV>Although this loops forever, as you intend, I would guess that it doesn't do so for the reason you think. Also it is very misleading code because people who are used to C would expect that 'while 0 ... end' would not loop at all, but in Ruby it is also an infinite loop. Ruby treats all values except false and nil as meaning 'true'.</DIV> <DIV> </DIV> <DIV>Secondly, Ruby provides an infinite loop method: 'loop {block}'. I would use this in preference to 'while true ... end'.</DIV> <DIV> </DIV> <DIV>Finally, please refactor your program before publishing the article. The code, as it is, is poorly structured and therefore not a good example of Ruby -- the script uses global variables for no reason, the methods are far too long, code structures are repeated instead of being abstracted as methods, and so on. Also, the program doesn't use any of Ruby's interesting features, such as creating domain specific iteration statements. I would suggest rewriting the example using these kind of idioms, otherwise all you are demonstrating is that Ruby has a different syntax to Perl. You could also demonstrate Ruby's open classes by defining your iterators as methods of the built-in File class, and demonstrate Ruby's singleton methods by adding methods to the STDIN object.</DIV> <DIV> </DIV> <DIV>E.g. the main loop should look something like this:</DIV> <DIV> </DIV> <DIV>File.open( address_file ) do |file|</DIV> <DIV> STDIN.each_address_input do |addr|</DIV> <DIV> file.write_address( addr )</DIV> <DIV> end</DIV> <DIV>end</DIV> <DIV> </DIV> <DIV>The each_address_input method is a singleton method that reads addresses from the input stream until the user inputs END. </DIV> <DIV> </DIV> <DIV>The write_address method would write an address into the file in the standard format.</DIV> <DIV> </DIV></FONT></DIV></BODY></HTML> ------ extPart_000_0057_01C129DE.F084AD30--