print 'test' if($x == 2);
In php that becomes
if($x == 2) echo 'test';
Not strictly longer but the phrasing feels wrong.
Extending the chain class like so I can do this:
class Puts extends Chain{
var $val;
function __construct($val){
parent::__construct();
$this->val = $val;
}
function __if($condition){
if($condition) echo $this->val."\n";
}
}
function puts($string){
$new = new Puts($string);
return $new;
}
$x = 2;
puts('this is an assertion')->if($x == 2);
#this would be nice for debugging
puts('this is a debug message')->if(DEBUG);
1 comment:
now that's just crazy talk
Post a Comment