From caab1c203cc996c521fc7115aab0991e1e53e05c Mon Sep 17 00:00:00 2001 From: Tomoyuki Sahara Date: Wed, 8 Feb 2017 18:31:50 +0900 Subject: define IO#hash to override Enumerable#hash. fixes #73. Current implementation of Enumerable#hash calls #each to collect hash values of enumerated objects (then calculates the hash value of the Enumerable object). But IO#each is a method to read lines. It is not expected that IO#hash reads all lines from the IO object. Or even worse, program waits for the IO object to be readable if it is a socket or something cannot be read immediately. --- mrblib/io.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/mrblib/io.rb b/mrblib/io.rb index 0b10c82aa..08f9180dd 100644 --- a/mrblib/io.rb +++ b/mrblib/io.rb @@ -114,6 +114,12 @@ class IO self end + def hash + # We must define IO#hash here because IO includes Enumerable and + # Enumerable#hash will call IO#read... + self.__id__ + end + def write(string) str = string.is_a?(String) ? string : string.to_s return str.size unless str.size > 0 -- cgit v1.2.3