16 May 21:09
How to put a block into an Array
From: David Finlayson <dfinlayson <at> usgs.gov>
Subject: How to put a block into an Array
Newsgroups: gmane.comp.lang.smalltalk.squeak.beginners
Date: 2008-05-16 19:11:50 GMT
Subject: How to put a block into an Array
Newsgroups: gmane.comp.lang.smalltalk.squeak.beginners
Date: 2008-05-16 19:11:50 GMT
Newbie here, working my way through Guzdial's Squeak: Object-Oriented Design with Multimedia Applications (2001). One of the exercises requires building an Array with a block of code as an element, the idea is to lookup the stored block in some way and execute it. But, how do you store a block of code in an Array? For example, I can do this: [Transcript show: 'a message'] value But I can't get this to work: myArray := #([Transcript show: 'a message']). (myArray at: 1) value The reason is that (myArray at: 1) doesn't recognize the stored object as a block. Inspecting it shows the odd symbol: #[ ?? Can someone get me back on the clue train? Thanks, David
RSS Feed