From: Bob Alexander Date: 2001-07-11T04:11:19+09:00 Subject: [ruby-talk:17628] Strange warning What exactly does Ruby's warning message "warning: block for Proc#call is useless" mean? I'm getting it in a case where it doesn't seem appropriate. The code executes several times with no problem, but the warning comes out every so often (this executes in a loop). Inserting an arbitrary statement can make it go away. For example, inserting "$stderr.putc(?Z)" right after the "openQueue()" prevents it, but inserting "x=33" in the same place does not (timing?). The code seems to run fine despite the warnings, but I have a nagging thought that there might be something wrong that I just can't see. Any ideas? This is under Ruby 1.6.4, FreeBSD 4.0. Bob Code fragment: # # Lock the queue and get header data. # openQueue(true) # # Look for an entry in the in-process set which has no "owner". # begin Dir.foreach(@inProcessDir) do |inProcessName| <------ "warning: block for Proc#call is useless" next if inProcessName == '.' || inProcessName == '..' inProcessPath = File.join(@inProcessDir, inProcessName) if inProcessFile = openAndLock(inProcessPath, "r+", File::LOCK_EX | File::LOCK_NB, true) entry = inProcessFile.read() unless inProcess File.delete(inProcessPath) inProcessFile.close() end @inProcessFile = inProcessFile closeQueue() @wasInProcess = true return entry end end rescue Errno::ENOENT end