📜 ⬆️ ⬇️

Features of working with variables and literals in Perl6

Not long ago, I decided to start learning Perl6, even despite the fact that there is still no fully working compiler. I thought that it was possible to watch Synopsis , to see which of what was written in them was already working, and to study exactly how it worked with various examples. I started doing this, writing down the results of various manipulations with variables to myself in my notebook.
And as my first post I decided to share my knowledge: what the authors of the material usually leave to an independent “study” - answers to questions like “what will happen if ...” or “and what is this in the language ".
In this article I will describe what basic data types there are in this language and partially address the issue of contexts - one of the main features of the Perl language.

Types of variables and types of their possible values.
Perl6 has 3 main types of variables: Scalars, Arrays, Hashes.
To declare a variable, the my keyword is used to declare a local variable, our is to declare a global variable (These are not the only ways to declare variables, but for now it will be enough).


Contexts
We now turn to contexts.
Perl 6 is context sensitive, which means that under different conditions of using a variable, different values ​​may be returned. First of all, the context is determined by which variable will be assigned a value:
$ a = ... - sets the scalar context, @a = ... sets the list context, etc.
The following contexts are available:

Well, on this my little experience of manipulating variables is so far limited. I hope that you here saw something new for you, and interesting. Have a good day!

')

Source: https://habr.com/ru/post/152403/


All Articles