From: Allen Mitchell Date: 2002-05-02T18:23:36+09:00 Subject: RE: require and case I've noticed this before, but in a different context: Consider the following: # a.rb class A @@createdCount = 0 def initialize @@createdCount += 1 end def A.utilization @@createdCount end end # main.rb require 'a.rb' a1 = A.new p A.utilization # => 1 # sub.rb require 'A.rb' # <===== CASE CHANGE p A.utilization # => 0 ! OOPS ############## It appears that because of the case difference, Ruby thinks that this is the first time loaded and re-evaluates the class members. This should definitely be looked at. I to agree that "require" might want to be case insensitive. -----Original Message----- From: Martin Stannard [mailto:martin@massive.com.au] Sent: May 1, 2002 10:24 PM To: ruby-talk ML Subject: require and case >ruby -v ruby 1.6.5 (2001-09-19) [i586-mswin32] ======================= require 'Date' require 'date' puts Date.new(2002, 4, 28) ========================= F:\fish\projects\test>e:\rubywin32\bin\ruby F:\fish\projects\test\datetest.rb e:/rubywin32/lib/ruby/1.6/date.rb:8: warning: already initialized constant IDENT e:/rubywin32/lib/ruby/1.6/date.rb:11: warning: already initialized constant MONTHNAMES e:/rubywin32/lib/ruby/1.6/date.rb:13: warning: already initialized constant DAYNAMES e:/rubywin32/lib/ruby/1.6/date.rb:15: warning: already initialized constant ITALY e:/rubywin32/lib/ruby/1.6/date.rb:16: warning: already initialized constant ENGLAND e:/rubywin32/lib/ruby/1.6/date.rb:17: warning: already initialized constant JULIAN e:/rubywin32/lib/ruby/1.6/date.rb:18: warning: already initialized constant GREGORIAN e:/rubywin32/lib/ruby/1.6/Date.rb:148:in `new3': invalid date (ArgumentError) from e:/rubywin32/lib/ruby/1.6/date.rb:150:in `new3' from F:\fish\projects\test\datetest.rb:5 It took me a while to track this down as the 2 requires were in different files. Should require be case insensitive or should it give a warning if the module it's trying to load has different case to that specified? regards, Martin