From: Johan Veenstra Date: 2007-12-29T01:51:25+09:00 Subject: Re: def if ; end - basically impossible? ------=_Part_7729_16568683.1198860690497 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline 2007/12/28, Giles Bowkett : > > 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. > You have defined a function namen "if", and you can call this function with send(:if), but this doesn't override the if-else/elsif-end construct. ------=_Part_7729_16568683.1198860690497--