< The Science of Programming < SwayPresentations < Objects 
      Examples
How about with?
   function with(obj,$actions)
       {
       $actions . context = obj;
       force($actions);
       }
Let's create an object:
   function f(x) { var y = x + 1; this;}
   
   var o = f(3);
Now let's modify its slots:
   with (o)
       {
       x = 10;
       y = 13;
       }
Did it work?
inspect(o . x); inspect(o . y);
Output:
o . x is 10 o . y is 13
    
    This article is issued from Wikibooks. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.