Skip to content

Instantly share code, notes, and snippets.

@Ovid
Created February 8, 2021 10:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Ovid/54e72c51caf4c56fe3c86ce1d6964fb2 to your computer and use it in GitHub Desktop.
Save Ovid/54e72c51caf4c56fe3c86ce1d6964fb2 to your computer and use it in GitHub Desktop.
user-defined attributes in Cor?
class Counter {
# My::Cor::Attributes is using some hypothetical
# tool to extend Cor attributes. Because it's a
# `use` statement, it happens at compile time
use My::Cor::Attributes ':isa';
has $count :reader :new :isa(PositiveInt) = 0;
method inc () { $count++ }
method dec () { $count-- unless 0 == $count }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment