Copy a string

AUTHOR

Stephen "thundergnat" Schulze

This task is about copying a string. Where it is relevant, distinguish between copying the contents of a string versus making an additional reference to an existing string.

More

http://rosettacode.org/wiki/Copy_a_string#Raku

use v6;



# There is no special handling needed to copy a string.
{
    my $original = 'Hello.';
    my $copy = $original;
    say $copy;            # prints "Hello."
    $copy = 'Goodbye.';
    say $copy;            # prints "Goodbye."
    say $original;        # prints "Hello."
}

# You can also bind a new variable to an existing one so that each refers
# to, and can modify the same string.
{
    my $original = 'Hello.';
    my $bound := $original;
    say $bound;           # prints "Hello."
    $bound = 'Goodbye.';
    say $bound;           # prints "Goodbye."
    say $original;        # prints "Goodbye."
}

# vim: expandtab shiftwidth=4 ft=perl6

See Also

100-doors.pl

100 Doors

24-game.pl

24 game

accumulator-factory.pl

Accumulator factory

ackermann-function.pl

Ackermann function

arbitrary-precision-integers.pl

Arbitrary-precision integers (included)

balanced-brackets.pl

Balanced brackets

binomial-coefficient.pl

Binomial Coefficient

create-a-two-dimensional-array-at-runtime.pl

Create a two-dimensional array at runtime

hailstone-sequence.pl

Hailstone sequence

last-fridays-of-year.pl

Last fridays of the year

prime-decomposition.pl

Prime decomposition

README.md

The Camelia image is copyright 2009 by Larry Wall. "Raku" is trademark of the Yet Another Society. All rights reserved.