> Hi All,
>
> Today, when I debug, I found that I don't understand a very basic
> function "super".
>
> <code>
>
> class User < ActiveRecord::Base
>  def self.columns
>    puts "here....................."
>    @ret = super
>    return @ret
>  end
>
> end
> </code>
>
> This return only one line of "here.....................". It is very
> fine. However, when I called
>
> My codes are:
> <code>
>
> class User < ActiveRecord::Base
>  def self.columns
>    puts "here....................."
>    super
>  end
>
> end
> </code>
>
> The return is what I expected - a list of columns in User, but this
> display 18 lines of "here....................." in the console (the
> length of "columns" of my User is 17.
>
> What is the difference between the two super call?

These two methods should both print the line
"here....................." to standard output before they return an
array of column objects. I'm not sure why you're getting different
results. Note that the super keyword has different semantics in Ruby
than for example Java -- I'd suggest consulting the Pickaxe or Ruby
for Rails if you're confused about its behaviour.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to