CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate:
Class::InsideOut - set default attribute value

 



waltz
Novice

Jun 16, 2011, 1:58 AM

Post #1 of 3 (753 views)
Class::InsideOut - set default attribute value Can't Post

How can i set default attribute value ? ..for example i want set attrbiute as anonymous array [] .

I looking into manul, but i cannot find answer :(

Thank for help

R.


BillKSmith
Veteran

Jun 16, 2011, 4:15 AM

Post #2 of 3 (748 views)
Re: [waltz] Class::InsideOut - set default attribute value [In reply to] Can't Post

The attriutes hashes in an "inside out" constructer are the same as ordinary variables in an ordinary (non OO) subroutine. If zero or '' are not valid values use:


Code
  

$attribute{$object} = 'default' or @_[1];



else:


Code
  

$attribute{$object} = defined @_[1] ? @_[1] : 'default';

Good Luck,
Bill


waltz
Novice

Jun 16, 2011, 5:02 AM

Post #3 of 3 (747 views)
Re: [BillKSmith] Class::InsideOut - set default attribute value [In reply to] Can't Post

..after redefined 'new' constructor it works

thank you

R.

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives