Kurso de Raku / Esencoj / Pli pri tipoj / Tipitaj variabloj / Exercises / Ekzameni
la rezulton de prompt — Ĉenoj
Solvo: Ekzameni la
rezulton de prompt — Ĉenoj
Kodo
Here is the complete program that does the job and prints both the entered string and its type.
my $name = prompt 'What is your name? ';
say $name;
say $name.WHAT;🦋 You can find the source code in the file prompt-strings.raku.
Testaj kuradoj
Run the program a couple of times and enter different names. The
program echoes the input and also reports that the variable contains a
string, in other words, an object of the Str type.
$ raku exercises/data-types/prompt-strings.raku
What is your name? Andrey
Andrey
(Str)Now, run the program again, type a few spaces instead of a name, and press Enter.
$ raku exercises/data-types/prompt-strings.raku
What is your name?
(Str)We do not see the output, but we see that the type of the variable is
still Str.
Kursa navigado
← Ekzameni
la rezulton de prompt — Ĉenoj | Ekzameni
la rezulton de prompt — Nombroj →