From: Aashish Kiran Date: 2010-01-09T03:15:56+09:00 Subject: Re: can you explain code Aldric Giacomoni wrote: > Aashish Kiran wrote: >> >> ---------------------ruby code-------------------- >> >> after running ruby code >> >> in below output at first occurrence of >> >> "sssssssssssssssssssssss" >> >> 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 "sssssssssssssssssssssss" "checkedValues" ["value6"] "nearValues" [nil] "sssssssssssssssssssssss" "checkedValues" ["value3"] "nearValues" [nil, "value6"] "sssssssssssssssssssssss" "checkedValues" ["value2"] "nearValues" [nil, "value3", "value6"] "sssssssssssssssssssssss" "checkedValues" ["value1"] "nearValues" [nil, "value2", "value3", "value4", "value5", "value6"] "i" 3 -- Posted via http://www.ruby-forum.com/.