On Jun 9, 2004, at 18:13, Chris Reay wrote:
>>      begin
>>        timeout(timeout) do
>>          while true
>>            if select([@sock], [], [], 0.1)
>>              retval += @sock.recv(256)
>>              if stop_pattern
>>                if retval =~ stop_pattern
>>                  break
>>                end
>>              end
>>            end
>>          end
>>        end
>>      rescue Timeout::Error
>>        timed_out = true
>>      end
> A reference TFM shows that select(rdArr, <wrArr>, <errArr>, <timeOut>)
> returns anArray or nil. [[mySock], [], []] == true returns false (I
> suppose).

Well since select() returns anArray or nil, if it returns 'nil', nil 
evaluates to false in conditionals, but anything else, other than 
'false', evaluates to true.  So if it returns an array of arrays, or an 
array, or even an empty array, it will evaluate to true:

irb(main):001:0> var = nil
=> nil
irb(main):002:0> if var then puts "#{var.inspect} is true(ish)" end
=> nil
irb(main):003:0> var = false
=> false
irb(main):004:0> if var then puts "#{var.inspect} is true(ish)" end
=> nil
irb(main):005:0> var = true
=> true
irb(main):006:0> if var then puts "#{var.inspect} is true(ish)" end
true is true(ish)
=> nil
irb(main):007:0> var = []
=> []
irb(main):008:0> if var then puts "#{var.inspect} is true(ish)" end
[] is true(ish)
=> nil
irb(main):009:0> require 'socket'
=> true
irb(main):010:0> sock = TCPSocket.new('localhost', 80)
=> #<TCPSocket:0x23d4dc>
irb(main):011:0> var = sock
=> #<TCPSocket:0x23d4dc>
irb(main):012:0> if var then puts "#{var.inspect} is true(ish)" end
#<TCPSocket:0x23d4dc> is true(ish)
=> nil
irb(main):013:0> var = [[sock], [], []]
=> [[#<TCPSocket:0x23d4dc>], [], []]
irb(main):014:0> if var then puts "#{var.inspect} is true(ish)" end
[[#<TCPSocket:0x23d4dc>], [], []] is true(ish)
=> nil
irb(main):015:0> [[sock], [], []] == true
=> false

Ben