Blogged by Ujihisa. Standard methods of programming and thoughts including Clojure, Vim, LLVM, Haskell, Ruby and Mathematics written by a Japanese programmer. github/ujihisa

Tuesday, April 27, 2010

Several Ways of Defining Class/Instance Methods

This entry is for Ruby beginners.

Class Methods

Assume you have class A and want to define a class method c.

  1. class + def + self.

    class A
    def self.c
    'hi'
    end
    end
    view raw gistfile1.txt hosted with ❤ by GitHub