>>>>> "Andy" == Andy Burnett <andy.burn...@knowinnovation.com> writes:
Andy> Randal said... Andy> <<With classic smalltalk 80 and Squeak: Andy> a := (1 to: 10) do: [:n | [n]]. Andy> b := a collect: [:each | each value]. Andy> b will have something like #(10 10 10 10 ...). Argh. That should have been collect: not do: Andy> Out of curiosity I tried changing it to [:n | [n*10]], expecting the numbers Andy> to be ten times bigger, but they were stil 1, 2, 3... I also tried removing Andy> the whole block, and b still evaluated to the same values. Works better with collect. :) a := (1 to: 10) collect: [:n | [n * 10]]. b := a collect: [:each | each value] b is now #(10 20 30 40 50 60 70 80 90 100) in a closure world. In non-closure, it would have been 100, 100, 100... -- Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095 <mer...@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/> Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc. See http://methodsandmessages.vox.com/ for Smalltalk and Seaside discussion _______________________________________________ Beginners mailing list Beginners@lists.squeakfoundation.org http://lists.squeakfoundation.org/mailman/listinfo/beginners