actionscript 3 - pass < or > operator into function as parameter? -


inside function there if() statement this:

if(passedvalue < staticvalue) 

but need able pass parameter dictating whether if expression above or is:

if(passedvalue > staticvalue) 

but cant pass < or > operator in has parameter, wondering best way this?

also if language using matters actionscript 3.0

thanks!!

instead of passing operator, impossible in as3, why not pass custom comparison function?

function actualfunction(passedvalue:number, comparefunction:function) {     /* ... */      if(comparefunction(passedvalue, staticvalue)) {         /* ... ... */     }      /* ... */ } 

then use it:

actualfunction(6, function(x:number, y:number) {      return x > y; }); 

or:

actualfunction(6, function(x:number, y:number) {      return x < y; }); 

Comments

Popular posts from this blog

ruby - When to use an ORM (Sequel, Datamapper, AR, etc.) vs. pure SQL for querying -

php - PHPDoc: @return void necessary? -

c++ - Convert big endian to little endian when reading from a binary file -