ulfben icon

using the Function type

ulfben | PRO | 01/09/17 01:44:22 PM UTC | 0 ⭐ | 11730 👁️ | Never ⏰ | []
ActionScript 3 |

0 B

|

None

|

0 👍

/

0 👎

var myFunc:Function = function():void{
    trace("test");
}
 
myFunc.call(); //"test"
myFunc(); //same thing as above
 
var multiplyWithEight:Function = makeMultiplierOf(8);
var result:Number = multiplyWithEight(2);
trace(result);
        
 
public function makeMultiplierOf(x:Number):Function{
    return function(y:Number):Number{
        return x * y; //notice; the function still have access to x when we call it later! 
                        //that is a "closure"
    };
}

Comments

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎

    
        
  • Rteuixl icon
    04/02/26 04:51:43 PM UTC
    text |

    0 B

    |

    0 👍

    /

    0 👎

    Best t33n active cpx link daily updates!
     Copy and paste the link in a new browser tab and then hit enter!
     https://crazyporn.@xxx/members/157354/?asgtbndr=1&play=true&spon=adworld&zone=400
     Remove the @ 
  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎

    
        
  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎