Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Perl6: Smartmatch scalar to array

by Fox (Pilgrim)
on Aug 16, 2010 at 17:41 UTC ( #855331=note: print w/replies, xml ) Need Help??


in reply to Perl6: Smartmatch scalar to array

 $scalar ~~ any(@array)
does what you meant, don't know if it's supposed to be the default though.

Replies are listed 'Best First'.
Re^2: Perl6: Smartmatch scalar to array
by TimToady (Parson) on Aug 16, 2010 at 20:14 UTC
    Indeed, it is precisely because Perl 6 has junctions that we do not need to assume junctional semantics on smartmatched lists; Perl 5 does not have junctions, so it does assume that. Instead, Perl 6 can use a list to smartmatch another list, which is also a useful behavior--especially since wildcards are supported. For instance, (1,2,3,4,5) ~~ (*,2,3,*) returns true.

      Thanks. I had assumed that smartmatch would be identical between Perl 5 and Perl 6, but I like the Perl 6 way better. It seems more maintainable.

      Also, thanks for all of your work on all of the Perls.

Re^2: Perl6: Smartmatch scalar to array
by molecules (Monk) on Aug 16, 2010 at 18:38 UTC
    Thanks. That also makes the intent clearer.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://855331]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (2)
As of 2021-12-06 13:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    R or B?



    Results (32 votes). Check out past polls.

    Notices?