Created
July 5, 2012 08:32
-
-
Save hoelzro/3052303 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl6 | |
use v6; | |
class Counter { | |
has $!n; | |
method new($n) { | |
return self.bless(*, :$n); | |
} | |
method is-counting { | |
return $!n > 0; | |
} | |
method tick { | |
$!n--; | |
} | |
} | |
my $c = Counter.new(10); | |
while $c.is-counting { | |
say $c.tick; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment