Changeset 5357
- Timestamp:
- 06/19/09 07:39:59 (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Padre-Plugin-Perl6/lib/Padre/Plugin/Perl6/share/templates/p6_class.p6
r5354 r5357 1 1 use v6; 2 2 3 class Foo { 3 =begin Pod 4 An example of a Perl 6 class 5 =end Pod 6 class Point { 7 # attributes; 8 # note that variable initialization is not automatic in Perl 6 9 has $.x = 0; 10 has $.y = 0; 11 12 # a method to move to a new location 13 method move($new_x, $new_y) { 14 $.x = $new_x; 15 $.y = $new_y; 16 } 17 18 method to_string() { 19 return $.x ~ "," ~ $.y; 20 } 4 21 } 22 23 # Create a point and initializes its attributes 24 my $pt1 = Point.new(); 25 my $pt2 = Point.new(:x(7), :y(8)); 26 say $pt1.to_string; 27 say $pt2.to_string;
Note: See TracChangeset
for help on using the changeset viewer.
