GST crashes with the following code

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

GST crashes with the following code

ZuLuuuuuu
Hi,

GST crashes when I try to run this code:


1 to: 5 do: [:x |
        1 to: 5 do: [:y |
                #(x y)
        ]
]


Are there any logic errors I made here?



_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk
Canol Gökel
Reply | Threaded
Open this post in threaded view
|

Re: GST crashes with the following code

Paolo Bonzini-2
Canol Gokel wrote:

> Hi,
>
> GST crashes when I try to run this code:
>
>
> 1 to: 5 do: [:x |
> 1 to: 5 do: [:y |
> #(x y)
> ]
> ]

It does not crash, it just says

stdin:6: expected true, false or nil

:-)

You want "{x. y} printNl" instead of #(x y).

Paolo


_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk
Reply | Threaded
Open this post in threaded view
|

Re: GST crashes with the following code

ZuLuuuuuu
Paolo Bonzini <bonzini <at> gnu.org> writes:

>
> It does not crash, it just says
>
> stdin:6: expected true, false or nil
>
>
>
> You want "{x. y} printNl" instead of #(x y).
>
> Paolo
>


Hi, may I ask what the braces do there? Are there making some kind of block so
that printNl effects both of them?

I should create an array of x and y because, in my actual code, I am passing it
to a method which take an array as argument. I didn't understand why it gives
"stdin:6: expected true, false or nil" error.



_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk
Canol Gökel
Reply | Threaded
Open this post in threaded view
|

Re: Re: GST crashes with the following code

Paolo Bonzini-2

>> You want "{x. y} printNl" instead of #(x y).
>
> Hi, may I ask what the braces do there? Are there making some kind of block so
> that printNl effects both of them?

The #(...) syntax is only for constant arrays.  Non-constant arrays are
created with the "tuple syntax" {x. y} (each element is separated by a
period.

> I should create an array of x and y because, in my actual code, I am passing it
> to a method which take an array as argument. I didn't understand why it gives
> "stdin:6: expected true, false or nil" error.

Within constant arrays the only symbolic variables that are allowed are
true, false and nil.

Paolo


_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk