On Thu, Nov 6, 2008 at 10:00 AM, Emil Sandin <esandin / gmail.com> wrote: > Hi, is there an easy way to redefine 'while'. I have a class that uses a > while loop. In my unit test it always evaluates to false (which is > correct). I only want the loop to run once, and the enter. Just like an > if. > > This is the code I've tried: > > > def while(condition) > p "redefined while!" > yield if condition > end > > while true do > p "hello" > sleep 1 > end > > > But it loops eternally. > Any help? > -- > Posted via http://www.ruby-forum.com/. > > Not possible. 'while' is a keyword, not a method. Jason