Login  Register

Re: Use of -> in Pharo Code

Posted by Martin McClure-2 on Nov 30, 2016; 5:13am
URL: https://forum.world.st/Use-of-in-Pharo-Code-tp4925229p4925232.html

On 11/29/2016 06:48 PM, Bruce Prior wrote:
I have been away from smalltalk coding for a while. On returning to the fold, I often see the use of a right arrow in code. Is this something new?

Today in a Teapot app example, I saw,

Teapot on GET: '/welcome' -> 'Hello World!'; start.

What is the arrow for?

As Sebastian said, #-> is a message that creates an Association, with the receiver as the key and the argument as the value of the Association. This has actually been around a very long time, though perhaps it's getting more widely used these days. It doesn't appear to be in the Blue Book, but I think it was probably actually in the Smalltalk-80 image 1 release.

I'm not *quite* curious enough to verify that by rooting around in my basement for the machine that actually runs that version and seeing if it will still power up after all these years. :-)

Regards,

-Martin