| |
| Recipe 1.4: Declaring Attributes |
Last Updated: Sep 8, 2003
Status: Very Likely
|
|
|
|
How important is this problem to you?
(Login to Vote)
5.00 Rating, 5 Votes
|
|
How acceptable is the proposed solution?
(Login to Vote)
3.60 Rating, 5 Votes
|
|
Problem:
   
You want to declare an attribute of a class.
Solution:
  
Use has:
class MyClass {
has $.counter;
}
Discussion:
The has keyword allows you to declare attributes of a class.
See later recipes for declaring attributes as specific types, providing initial values to attributes, and for getting and setting attribute values.
|
|