Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating multiple variables in Pharo gives me a "variable or expression expected" error

I'm confused about why this code seems to work fine in isolation, but I get an error when I put it all together.

The following snippet prints 'Hello World!' when printed:

| blah |
blah := 'Hello '.
blah, 'World!'.

But the following code block gives me the error Variable or expression expected

| blah |
blah := 'Hello '.
blah, 'World!'.
| blah2 |
blah2 := 'World!'.
blah, blah2.

Could someone explain what's going on here?

like image 990
Kreg Avatar asked Jan 17 '19 00:01

Kreg


1 Answers

variable declarations are only allowed at the beginning of a block or method:

| blah blah2 |
blah := 'Hello '.
blah, 'World!'.

blah2 := 'World!'.
blah, blah2.
like image 169
eMBee Avatar answered Nov 28 '22 00:11

eMBee