Perl6 Object Oriented Cookbook (v0.2.1)  
Section 4: Inheritance  
 
Recipe 4.2: Inheriting from Builtin Types
Last Updated: Sep 8, 2003
Status: Draft
      Previous Page   Next Page

How important is this problem to you?
  (Login to Vote)
5.00 Rating, 3 Votes  

How acceptable is the proposed solution?
  (Login to Vote)
5.00 Rating, 2 Votes  

Problem:  

You want your class to inherit from a builtin type.

Solution:  

Just do it:

class MyScalar is scalar {
    ...
}

Discussion:

Subclassing builtin types is an extremely powerful way to create objects that act, for almost all intensive purposes, like those builtin types. See Section 6 to learn what builtin types exist in perl, and how to subclass them.


Log In to Comment


Login / Edit User Info -- Copyright © 2002 Cognitivity -- Previous Page   Next Page