On 10/01/2017 09:17 AM, Brandon Allbery wrote:
              (b d)

    What does the ".succ" do?


In this case it's just an example of an expression that wouldn't have worked by normal interpolation (although $v.succ() would have, as I described earlier).

succ is short for "successor"; think of it as the generalized version of adding 1 to something. In Perl 6, it can be used (but ideally shouldn't) on numbers, or to get the next element of an Enum (note that this might not necessarily correspond to its numeric value plus one), or as in this case to get the next notional "value" of a string: this is a somewhat rationalized version of Perl 5's "magic autoincrement" and is described at https://docs.perl6.org/type/Str#method_succ . It's useful, especially in the form of the ++ autoincrement operator, for autogenerating filenames.

     pyanfar Z$ 6 'my $x = "file1.txt"; say $x.succ'
     file2.txt



Sweet!  Perl 6 thinks of EVERYTHING.

Thank you!

Reply via email to