From: Rick DeNatale Date: 2007-12-29T01:44:01+09:00 Subject: Re: def if ; end - basically impossible? On Dec 28, 2007 11:21 AM, Giles Bowkett wrote: > I'm writing some code which needs to do something unusual when it > encounters an if, an else, or an end. > > >> def if > >> "asdf" > >> end > => nil > >> if > ?> true > >> end > => nil > > The ?> line comes up because if appears to not be a method but an > operator or something similar, so my override does nada. > > Is there any way to do this? It looks as if I have to either rethink > my strategy or write some kind of parser. If is not a method, it's a reserved word. Ruby doesn't have many reserved words, but it has a few: __FILE__ , __LINE__, alias. and ,begin, BEGIN, break, case, class, def ,defined?, do, else, elsif, end, END, ensure, false. for, if, in, or, module, next, nil, not, redo, rescue, retry, return, self, super, then, true, undef, unless, until, when, while, and yield -- Rick DeNatale My blog on Ruby http://talklikeaduck.denhaven2.com/