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

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

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

unicode - Are email addresses allowed to contain non-alphanumeric characters? -