From: Aldric Giacomoni Date: 2010-01-09T04:43:44+09:00 Subject: Re: can you explain code Aashish Kiran wrote: > Aldric Giacomoni wrote: >> Aashish Kiran wrote: >>> >>> can anyone explain how "nearValues" is updating >>> >> (skip long useless code and output) >> >> Well, your code says this: >> >> nearValues.size.times do |i| >> n = nearValues[i] >> next if $hash2[n].include?(pivot) >> nearValues[i] = nil >> >> That means, er. .. If the pivot is in $hash2[n], whatever that means, >> then go to the next number. Otherwise, if the pivot is not in $hash2[n], >> nearValues[i] is set to nil. >> This, incidentally, is absolutely terrible Ruby, and I want to inflict a >> lot of pain to the person who wrote it. > > > thank you for reply > can you please explain how nearValues is adding values > No, because that's not in the code supplied. nearValues is passed to this method. The code is ugly but very readable. Go over it a few times and it will make sense. Hints: - "p" means "puts" and stands for 'send to the screen' (basically) - Unknown methods can be looked up here: http://ruby-doc.org/core/ -- Posted via http://www.ruby-forum.com/.