Search code examples
blocksmalltalkvisualworks

smalltalk returning string from block in VisualWorks


I want to return the value, that was passed int to the block. If it's a number, everything works great, but If I put in a String or boolean value, I get a "Message not understand".

q := [ :a | a].
Transcript show: ((q value:'123') value) printString.

I thought everything is treated the same, so I'm confused. But I guess I'm just missing something.

edit: it seem to work under Pharo...


Solution

  • The message "value" isn't implemented for Object in VisualWorks. Some applications add it in but it's not in the base class library. In some versions of VisualWorks it slipped into the base class library and was later taken out.

    If you write your code like this it will work:

    q := [ :a | a].
    Transcript show: (q value:'123') printString.