JJB Blog

Posts Tagged ‘class’

Ruby class methods — several ways to define them, and how to abstract them into a module/mixin

I learned/confirmed two things about Ruby class methods recently: several equivalent ways to define them, and how to abstract them into a module/mixin.

Ruby class, Class, and Module

irb(main):030:0> Class.class => Class irb(main):031:0> Class.superclass => Module irb(main):032:0> Module.class => Class irb(main):033:0> Module.superclass => Object irb(main):034:0> Object.class => Class irb(main):035:0> Object.superclass => nil So, should this (in particular the parts in bold) blow my mind, or is it just a standard Chicken-Egg situation that exists within the fundamental constructs of any programming language? I [...]