From: RichardOnRails Date: 2011-05-09T12:35:30+09:00 Subject: Re: Must be my bug, but it looks like Ruby's could it be? On Apr 30, 6:06 pm, 7stud -- wrote: > RichardOnRails wrote in post #995908: > > > I know my Subject line looks like heresy in this newsgroup, but I > > can't figure out how I'm screwing up in this bug. > > > I posted the program athttp://www.pastie.org/1849430 > > It reads in a little control data, which is displayed at > >http://www.pastie.org/1849434 > > > The program reads in the control data and stores it in hash containing > > two hashes in this case, which represents the two pseudo-hashes in the > > control data. > > > My problem is conflicting output by the statements numbered 155 & 156: > >     puts %[%d\t%s => %s] % [num+=1, key, value] > > I know about ruby's % substitutions, but I can't decipher that line--you > have obfuscated the code very well!  Not a good thing.   I would write > that line as: > > puts "%d\t%s => %s" % [num+=1, key, val] > > lol.  You are using the % shortcut for %Q and you are using [] as the > delimiter.  I have only one thing to say: horrible code writing. > > -- > Posted viahttp://www.ruby-forum.com/. Hi 7Stud, Thanks for your response. As I mentioned to Mike, I had more serious things to work on last week; hence, my belated response. >> puts %[%d\t%s => %s] % [num+=1, key, value] vs. > puts "%d\t%s => %s" % [num+=1, key, val] I used %[...] instead of "..." because I often want to include embedded double-quotes in my strings and believe my delimiting approach is clearer since I don't have to escape double-quotes. Nevertheless, I'm mindful of the ancient adage, de gustibus non est disputandum. As I also mentioned to Mike, I now realize that my parsing routine produced errors in in my control data. Rather than trying to correct my amateurish code, I'm going to study one of Ruby Design Patterns for application to this problems. Best wishes, Richard