Tags » Meta-programming

Momentum Programming (MP)

Inheritance and composition should actually be about programming of programming. This means that code is written once and duplication of semantically and logically same code is avoided by automating the process of generating the whole source code from parts. 766 more words

Java

Ruby : Various ways to define class methods

# 1
class Rubyist
  def self.who
    "Geek"
  end
end
p Rubyist.who # => "Geek"
# 2
class Rubyist
  class << self
    def who
      "Geek"
    end
  end
end

# 3
class Rubyist
end
def Rubyist.who
  "Geek"
end

#4
class Rubyist
end
Rubyist.instance_eval do
  def who
    "Geek"
  end
end
puts Rubyist.who # => Geek
… 21 more words
Ruby