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

Re: Need append help

Thread Previous | Thread Next
From:
ToddAndMargo
Date:
September 29, 2017 18:04
Subject:
Re: Need append help
Message ID:
00619189-7230-78ae-500d-c1f83845948b@zoho.com
On 09/29/2017 10:54 AM, Brandon Allbery wrote:
> On Fri, Sep 29, 2017 at 1:49 PM, ToddAndMargo <ToddAndMargo@zoho.com 
> <mailto:ToddAndMargo@zoho.com>> 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;'
abcdef


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


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About