Super: the Fat Jewish of Ruby methods

Day 135

In my brief coding journey, metaphors have become signposts to help me find or keep my bearing as we cruise from concept to the next. If they help me, perhaps they’ll help someone else, so as they pop up, I’ll share them. You can hope as my understanding grows, these metaphors will become more elevated. Knowing me though, that’s unlikely.

photo from hngn.com

Super takes methods from it’s superior related class, and uses them like they are its own …much like The Fat Jewish.

The keyword super allows an overridden method to be called by the overriding method. In the example below, both class Comedy and class Hack have the joke method. Without super, the joke method in class Hack would be not funny. Super allows Hack to access or use the Comedy joke method in addition to any joke method functionality from within it’s own class to become funny itself.

One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.