class A
def self.b
print "this is static methods"
end
end
You can only be able to call the method "b" by using : A.b
that wat I am trying to say.
On Wednesday, 28 November 2012 19:32:01 UTC+5:30, Jordon Bedwell wrote:
>
> On Wed, Nov 28, 2012 at 6:46 AM, thil <[email protected] <javascript:>>
> wrote:
> > Self.methods is static methods using the class name itself you can call
> the
> > methods and is not available to the instance of the class.
>
> There is no such thing as static methods in Ruby. self.method_name
> (or sometimes self.class.method_name) are instance methods on the
> singleton instance of the object (in 1.9 you can access the singleton
> via singleton_class too). Since everything is an object in Ruby
> (literally) you have multiple types of instances, in his case he is
> accessing instance methods on the singleton (or anonymous class or
> eigen, however you want to label it) vs instance methods on /an/
> instance of that object.
>
--
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 [email protected].
To unsubscribe from this group, send email to
[email protected].
To view this discussion on the web visit
https://groups.google.com/d/msg/rubyonrails-talk/-/lTNAl6MtriYJ.
For more options, visit https://groups.google.com/groups/opt_out.