Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR RUBY

call a class method ruby

class Foo
    def self.some_class_method
        puts self
    end

    def some_instance_method
        self.class.some_class_method
    end
end

print "Class method: "
Foo.some_class_method

print "Instance method: "
Foo.new.some_instance_method

Outputs:
  Class method: Foo
  Instance method: Foo
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #call #class #method #ruby
ADD COMMENT
Topic
Name
4+8 =