develooper Front page | perl.perl6.users | Postings from September 2017

Re: Need append help

Thread Previous | Thread Next
September 29, 2017 18:04
Re: Need append help
Message ID:
On 09/29/2017 10:54 AM, Brandon Allbery wrote:
> On Fri, Sep 29, 2017 at 1:49 PM, ToddAndMargo < 
> <>> wrote:
>     I am trying to find a shorter way of doing
>           $x = $x ~ "def"
>     But I can't seem to master "append"
>     What am I doing wrong?
> Again (as with last night in IRC) you are treating a string as a list. 
> But a string is a single thing; it doesn't make sense to list-append to it.
>      $x ~= "def";

$ perl6 -e 'my $x="abc"; $x ~= "def"; say $x;'

Perfect!  Thank you!

I am slowly getting away from my Modula 2 "Array of Characters" days.

Question:  Is thee a pretty way like the above to do a prepend?

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About