Re: Default argument values for blocks



>This one was proposed long ago as a way to declare a var whose scope is
> outside the block:
>
> lambda { <foo = 1|2> puts foo }

All sorts of things can work, one that looks quite nice:

lambda { foo = 1|2 -> puts foo }

But I would suggest that everyone give the -> () {} notation chance. I
really hated it at first too, but it has grown on me and I am starting
to like it even more then goal posts b/c of the way it brings the
parameters outside of the block.

T.

.



Relevant Pages

  • Re: function pointers vs direct calling in javascript
    ... scope tree to look for 'tempVar2' or for some other reason? ... Here is what I think of 'var', correct me if I am wrong. ... 'var' doesn't as such declare a variable. ... a property of the global object when the code executes. ...
    (comp.lang.javascript)
  • Re: function pointers vs direct calling in javascript
    ... //lots of entries in tempVar here ... Detailed explanation of the use of the var keyword? ... to *declare* variables or put them in the symbol tree in javascript. ... variable in a scope which is local to this function. ...
    (comp.lang.javascript)
  • Re: function pointers vs direct calling in javascript
    ... scope tree to look for 'tempVar2' or for some other reason? ... Detailed explanation of the use of the var keyword? ... to *declare* variables or put them in the symbol tree in javascript. ... variable in a scope which is local to this function. ...
    (comp.lang.javascript)
  • Re: Using temporary table in in dynamic SQL
    ... is defined ouside the scope of dynamic sql statement. ... declare @var table ...
    (microsoft.public.sqlserver.programming)
  • Re: Dynamic variable names
    ... Note that var defines the scope of a variable. ... variable you initialize belongs to the scope where it has been ... But it has been added no assignment yet, ...
    (comp.lang.javascript)