Warren Seltzer schrieb:
> The interpreter lets me make this mistake:
> 
> class Act 
> 	def Act.new
> 		# Anything, really
> 	end
> end
> ######
> 
> Coding your own "new" just seems to screw things up.  What is it good for and why isn't it a
> syntax error?
> 
> 
> Fred
> 
> 

You can write your own "new" method if it makes sense for your application. As I 
understood it correctly, the initialization process uses three methods: "new", 
"allocate", and "initialize".

 >>>>> Code >>>>>

class Otto
   def self.new(*p,&b)
     puts "Here do something special..."
     super(*p,&b)
   end
   def hi
     puts "'Hi!' from an 'Otto' instance"
   end
end
p Otto.new
Otto.new.hi

 >>>>> Output >>>>>

Here do something special...
#<Otto:0x2aeb148>
Here do something special...
'Hi!' from an 'Otto' instance

 >>>>> EoE >>>>>

Wolfgang NŠŇasi-Donner