Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re^3: Perl 6, Object Orientation and Melting Brains

by BrentDax (Hermit)
on Mar 28, 2005 at 23:56 UTC ( #443002=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    given ($payment_method) {  # All code samples are Perl 6
        when 'credit' { do_credit_card($num, $exp) }
        when 'debit'  { do_debit_card($num, $exp) }
        when 'check'  { do_check() }
        default       { die }
    }
    
  2. or download this
    class MyStore::PayMethod {
        # A submethod is a method that isn't inherited.
        submethod new { die "Create a subclass, silly." }
    ...
        method    execute($price) { (code to execute) }
        method    store($dbh) { (code to store) }
    }
    
  3. or download this
    my $class;
    given($payment_method) {
        when 'credit' { $class=MyStore::PayMethod::CreditCard }
    ...
        when 'check'  { $class=MyStore::PayMethod::Check      }
    }
    my $payobj=$class.new(*%params);
    

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (2)
As of 2022-05-28 03:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you prefer to work remotely?



    Results (98 votes). Check out past polls.

    Notices?