From: ts Date: 2001-09-11T21:21:13+09:00 Subject: [ruby-talk:21093] Re: Do literals invoke new? >>>>> "J" == Jason Voegele writes: J> 1) Do literals invoke new? a = [1, 2] a = {1 => 2} a = "12" is directly implemented via a node (NODE_ARRAY, NODE_HASH, NODE_STR) and don't call Array::new, Hash::new, String::new J> 2) What's wrong with the code below? J> # Replace standard new with custom new J> class Class J> alias_method :old_new, :new J> def new(*args) J> result = old_new(*args) J> puts "new invoked!" J> return result J> end J> end J> # Test to see if literals invoke new J> aString = "hello" J> anArray = [1,2,3] J> anotherArray = Array.new You redefine Class::new but not Array::new, in your last line this is Array::new which is called. -- Guy Decoux