fork download
  1. class BooleanCategory {
  2.  
  3. public static Boolean then(Boolean self, Closure c) {
  4. if(self) c()
  5. return self
  6. }
  7.  
  8. public static Boolean otherwise(Boolean self, Closure c) {
  9. if(!self) c()
  10. return self
  11. }
  12.  
  13. }
  14.  
  15. use(BooleanCategory) {
  16.  
  17. ('foo'.length() > 2).
  18. then { println 'yipee' }.
  19. otherwise { println 'bummer' }
  20.  
  21. }
Success #stdin #stdout 1.38s 219136KB
stdin
Standard input is empty
stdout
yipee