Login  Register

Don't understand Array creation syntax

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options Options
Embed post
Permalink
Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

Don't understand Array creation syntax

frankl1_miky
18 posts
Why the first element of #( ( 1 + 2 ) . 3 ) is #(1 #+ 2) and not #'('.
Thanks!!
Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

Re: Don't understand Array creation syntax

Damien Pollet-2
103 posts
That's just how the syntax is; it allows to have arrays as elements of arrays.

Also, to be coherent with what you thought, closing parentheses would have to become elements as well, and the array would never end.

On 12 June 2016 at 05:23, Franklin Mike <[hidden email]> wrote:
Why the first element of #( ( 1 + 2 ) . 3 ) is #(1 #+ 2) and not #'('.
Thanks!!

Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

Re: Don't understand Array creation syntax

frankl1_miky
18 posts
So if I understood it well, closing Parenthesis are telling that it's the same element in the Array
Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

Re: Don't understand Array creation syntax

Damien Pollet-2
103 posts
I don't understand what you've understood…

Parentheses need to be paired for the outer literal array to be recognized.

Technically, opening parentheses could become elements, but not closing parentheses, since then there would be nothing to close the literal array. And it would be strange to read if you could have several ((( but only one ) at the end.

Instead, pairs of parentheses enclose an array, which is nice because it makes it possible to have literal arrays as elements inside literal arrays. If you want a single parenthesis as an element, you have to explicitly write is using the symbol syntax.

On 14 June 2016 at 12:14, frankl1_miky <[hidden email]> wrote:
So if I understood it well, closing Parenthesis are telling that it's the
same element in the Array



--
View this message in context: http://forum.world.st/Don-t-understand-Array-creation-syntax-tp4900533p4900813.html
Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.


Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

Re: Don't understand Array creation syntax

frankl1_miky
18 posts
Thanks