calls to super at the end of initialise methods

Hi there,

whilst looking at the Rails source code, I noticed a number of methods that followed this pattern:

def initialize    #some initialisation code    super end

I thought that the appropriate way to do this was to call super before the init stuff, just in case the parent init code overrode the current init code.

Consider the following:

>> class First >> def cheese >> puts @cheese >> end >> def initialize >> @cheese = 'Stilton' >> end => nil >> Stilton => nil >> class Second < First >> def initialize >> @cheese = 'Shropshire Blue' >> super >> end => nil >> Stilton => nil >> class Third < First >> def initialize >> super >> @cheese = 'Cheshire' >> end => nil >> Cheshire

However, the occasional call to super at the end of a method may be because you desire this behaviour, I'm just being inquisitive :slight_smile:

An example where I imagine the super would be better placed at the beginning of the method:

(actionpack/lib/action_controller/cgi_process.rb) def initialize(cgi, session_options = {})        @cgi = cgi        @session_options = session_options        @env = @cgi.send(:env_table)        super() end

Cheers, Sam Aaron