From: Rick DeNatale Date: 2007-07-21T02:09:04+09:00 Subject: Re: overriding nil?, curiosity On 7/18/07, Stefan Rusterholz wrote: > Matt Greer wrote: > > Maybe this is a dumb question, but I'm gonna give it a shot. > > > > I was showing my friends how Ruby classes are always open and I did some > > dumb things like redefine Integer#+ to always return 5, and such. But > > trying > > this: > > > > NilClass.class_eval do > > def nil? > > false > > end > > end > > > > result in this: > > Taking a look at the code and I'm completely lost. Obviously Ruby itself > > depends on a usable definition of nil? I'm sure it depends on some key > > methods in String, Array etc to be defined as expected too. So I guess > > there > > Nope, not ruby. IRB. Because IRB is written in ruby. Back in 1983, the first widely avaiable official documentation on Smalltalk was published as four volumes, one on the language and it's implementaiton, one on the development environment, one on writing graphical applications, and the fourth called "Bits of History, Words of Advice" which captured various experiences of those who had implemented and used Smalltalk up to that point. The last volume is illustrated by many cartoons, one of my favorites comes early on and consists of a completely black frame with a word balloon containing "OOPS! I just typed 'Processor <- nil.'!" Languages like Ruby and Smaltalk give you great power to change the floor you're standing on, but as always, with great power comes great responsibility. -- Rick DeNatale My blog on Ruby http://talklikeaduck.denhaven2.com/