From: Ryan Davis Date: 2007-11-19T16:23:30+09:00 Subject: Re: False positives in editing data I realize you solved your problem, but there is a much more insidious underlying issues here: On Nov 18, 2007, at 22:40 , RichardOnRails wrote: >> MLN = 2 # MaxLeadingNumbers >> MLN >> sName =~ /^([\d]+)?\.?([\d]+)?\.?([\d]+)?\.?/ sName >> n = Array.new n >> print "DBG0>> "; (1..MLN+1).each { |i| >> printf("\t#{n[i]}") }; nasty compounded lines and obtuse debugging output >> i_thNumberExists = n[i] ? true : false >> iThNumbrerHasLeadingZero = i_thNumberExists && i_thNumberExists iThNumbrerHasLeadingZero ARGH! My eyes! STOP!!! Ruby is NOT C. For the love of all that is ruby, please write readable code! Use English variable names (or whatever your native language is--just use words). Don't use hungarian notation, it doesn't help--hell, your variable names are so ugly you can't even read the misspellings in them. Don't mix camelcase and underscores. Don't use 'n[i] ? true : false' when 'n[i]' would do. Don't debug with logging. Write tests. / [\d]+/ is the same as /\d+/. Those evals are TERRIFYING. Don't use them. And, most importantly, 2 spaces per indent. If you follow these suggestions, your code will be much more understandable and less error prone. Really.