No site found for codelikethis.herokuapp.com; using CodeLikeThis content.

 Slides

Classes as objects (advanced)

class Person

is syntactic sugar

same as

Person = Class.new

Note that Person is just a regular constant!

defining a class with class_eval

class Person
  def name
    "Alice"
  end
end

same as...

Person = Class.new
Person.class_eval do
  def name
    "Alice"
  end
end

the singleton class

aka "eigenclass" (but "metaclass" is incorrect)

method lookup

from http://blog.madebydna.com/all/code/2011/06/24/eigenclasses-demystified.html

method lookup goes through the eigenclass

method lookup

from http://blog.madebydna.com/all/code/2011/06/24/eigenclasses-demystified.html