Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: [OT] Perl / Computer Science Science Fair Projects

by tilly (Archbishop)
on Sep 09, 2008 at 05:30 UTC ( #709973=note: print w/ replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    var x = "hello "
    var my_closure = function (y) {
      alert(x + y);
    }
    my_closure("world");
    
  2. or download this
    for (@some_array) {
      # Declaring this in the loop creates a new variable per
    ...
      };
    }
    # We now have one closure per array element.
    
  3. or download this
    for (var i = 0; i < some_array.length; i++) {
      // Declaring this in the loop creates a one variable for
    ...
      });
    }
    // All closures now point at the last element.
    
  4. or download this
    for (var i = 0; i < some_array.length; i++) {
      // This declares and immediately calls a function, and x
    ...
      )(some_array[i]); // And here is where we bind the value.
    }
    // We now have one closure per array element.
    

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://709973]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (8)
As of 2015-07-04 14:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (60 votes), past polls