Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Thoughts on some new operators for perl (6 or 7)

by Roy Johnson (Monsignor)
on Mar 10, 2004 at 18:24 UTC ( #335547=note: print w/ replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    # syntax
    lvalue ?= op value;
    ...
    $highest ?= lt substr($_, 10, 5);
    # ex: $foo ||= $bar, using the generalized ?= operator
    $foo ?= || $bar;
    
  2. or download this
    # ex: $foo = $default if !defined($foo)
    $foo ?= !defined $default;
    # ex: $foo{'bar'} = $default if exists($foo{'bar'})
    # That is, we're resetting the value, but not creating it
    $foo{'bar'} ?= exists $default;
    
  3. or download this
    # $foo = uc($foo)
    $foo ?= uc;
    # even do arrays!
    @arr ?= reverse;
    
  4. or download this
    # $foo = 5 if -$foo?
    # $foo = $foo - 5 if $foo - 5?
    $foo ?= - 5;
    
  5. or download this
    $foo{$bar}{$baz} ?= -;
    

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (6)
As of 2015-07-03 20:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (56 votes), past polls