NerdyC

Welcome to the OCD nerd power hour.

RSS

How to fake the ‘new’ operator in Ruby

Jan 05, 2011

My friend Alejandro Crosa recently tweeted his wish that Ruby 1.9 include a ‘new’ operator like in Javascript and many other programming languages:

@nerdyc @ikai I kinda like it too, if 1.9 makes “new Class” work then all my typical javascript errors will disappear

So I decided to show him how to reproduce the new operator using Ruby meta-programming! For non-nerds, or people new to Ruby who might actually use this in real world code — THIS IS A JOKE.

About the Author

Portrait photo for NerdyC

A {food, computer, language} nerd who lived in NYC for 9 years, but is now much happier in SFO.

Stuff I Like

Following:

parislemon kkr theworldwelivein photojojo ohscience timoni superamit kthread dphiffer darrellsilver nattles jkottke americandrink annielin americanmccarver dianakimball colinmeloy abangupjob john mizginevra thoughtbot html5watch chiragdave leyink jessaclark rdeeming ericsuesz visivo netflixmoviesthatdontsuck fuckyeahamitgupta lazycrafter bikebasketpies kimjoar grubbin internetlovesamit jeanniechoe clairebrain enjoywhatyoudrink materialco youaremybestfriend venturecraftrepost philco bhaggs imnotdeadyet seaweedbutter marycrosse lovealgorithm topicalpickuplines tehawesodotme recombobulation whatwouldjoando