Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re^2: Bring back the smartmatch operator (but with sane semantics this time)!

by tobyink (Canon)
on Jun 11, 2014 at 20:56 UTC ( [id://1089598]=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    sub as_bool { $_[0] ? "true" : "false" }
    
    my @greetings = qw( Hi Bye );
    say as_bool("Hi" ~~ @greetings);     # true
    say as_bool("Hiya" ~~ @greetings);   # false
    
  2. or download this
    push @greetings, 0, 1;
    say as_bool(0 ~~ @greetings);       # true
    say as_bool(1 ~~ @greetings);       # true
    say as_bool(2 ~~ @greetings);       # false
    say as_bool("Hiya" ~~ @greetings);  # true ?!?!
    

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (2)
As of 2024-04-25 20:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found