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? The problem is that while is not a method in ruby but a keyword [reserved word]. http://www.zenspider.com/Languages/Ruby/QuickRef.html Michael Guterl