On Apr 11, 2006, at 8:13 AM, Ernest Micklei wrote: > Hi, > > For a long time I have been programming Smalltalk. > Recently, Ruby "got me" and I was wondering how the > famous ifTrue:ifFalse: could be added to the System. > > 1 = 2 > ifTrue: > [Transcript show: "true!" ] > ifFalse: > [Transcript show: "false!"] > > So at least the following works but I was hoping that it would have > the > same elegance. "proc" was needed to create a real block instance. Here's an alternate syntax that does away with the need to call proc(): >> class Object >> def true? >> yield self if self >> self >> end >> def false? >> yield self unless self >> self >> end >> end => nil >> (1 == 2).true? { puts "True!" }.false? { puts "False!" } False! => false >> (1 != 2).true? { puts "True!" }.false? { puts "False!" } True! => true Hope that gives you some fresh ideas. James Edward Gray II