Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add some enum-like methods to Bool.
  • Loading branch information
pmichaud committed Aug 3, 2011
1 parent c048df8 commit 0cd9e76
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/core/Bool.pm
@@ -1,18 +1,23 @@
my class Bool {
multi method Bool(Bool:D:) { self }

multi method Str(Bool:D:) {
self ?? 'Bool::True' !! 'Bool::False'
}
multi method Str(Bool:D:) { self ?? 'True' !! 'False' }

method Numeric() { self ?? 1 !! 0 }
method Int() { self ?? 1 !! 0 }

method pred() { Bool::False }

method succ() { Bool::True }

method key() { self.Str }
method value() { self.Numeric }

method pick(Bool:U: $n = 1) { (Bool::True, Bool::False).pick($n) }
method roll(Bool:U: $n = 1) { (Bool::True, Bool::False).roll($n) }

multi method ACCEPTS(Bool:D: Mu \$topic) { self }

multi method gist(Bool:D:) { self ?? 'Bool::True' !! 'Bool::False' }
}


Expand Down

0 comments on commit 0cd9e76

Please sign in to comment.