Jump to content

Apply a callback to an array: Difference between revisions

Line 518:
If I wanted to call "<tt>myfunc</tt>" on each element of <tt>dat</tt> and <tt>dat</tt> were a list:
 
<highlightSyntax language=tcltk>
foreach var $dat { myfunc $var }
</highlightSyntax>
 
if <tt>dat</tt> were an array, however:
 
<highlightSyntax language=tcltk>
foreach var [array names dat] { myfunc $dat($var) }
</highlightSyntax>
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.