Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why do + and ~ affect Perl 6 junctions differently?

Add one to a junction of Ints:

put any( 1, 3, 7 ) + 1;

Now you have a junction of those Ints increased by one:

any(2, 4, 8)

So, 2 == any(2, 4, 8) is true.

Make a junction of strings and append to those strings:

put any( <h H> ) ~ 'amadryas';

You get a different result that doesn't equal 'hamadryas' or 'Hamadryas':

any("h", "H")amadryas

I expected something like:

any( 'hamadryas', 'Hamadryas' );

What's the difference in these operations that gives them different behavior even though they should be similar?

like image 995
brian d foy Avatar asked Aug 06 '17 01:08

brian d foy


1 Answers

on the High Sierra 10.13, put fails with:

put any( 1, 3, 7 ) + 1

This type cannot unbox to a native string: P6opaque, Junction in block at line 1

perl6 -v

This is Rakudo Star version 2017.10 built on MoarVM version 2017.10 implementing Perl 6.c.

like image 56
chenyf Avatar answered Jan 05 '23 02:01

chenyf