Get the latest tech news

Implementing a simple object system from scratch in Ruby


“What I cannot create, I do not understand.” – Richard Feynman

We’ll implement method lookup, prototypical inheritance, mixins and some form of metaprogramming. Let’s create a module, which will serve as a namespace for our constructor and other utility functions related to our class. Anonmyous functions we store in the hash object are closures, so they capture the environment in which they were defined.

Get the Android app

Or read this on Hacker News

Read more on:

Photo of Scratch

Scratch

Photo of ruby

ruby

Photo of simple object system

simple object system

Related news:

News photo

Show HN: I designed an espresso machine and coffee grinder

News photo

Diamonds can now be created from scratch in the lab in 15 minutes

News photo

Scratch and Sniff Stickers and the Gas Panic of '87