Permalink
Browse files

Make .list, .flat, .eager & .hash type object aware.

If called on just a type object, they will all return an empty list/hash.
  • Loading branch information...
1 parent 340fc12 commit d12ecc5c8bbcdd97936738cbf0156c5f37f69b3f @lizmat lizmat committed Jul 24, 2013
Showing with 18 additions and 4 deletions.
  1. +18 −4 src/core/Any.pm
View
@@ -13,10 +13,24 @@ my class Any {
# primitives
method infinite() { Nil }
- method list() { nqp::p6list(nqp::list(self), List, Mu) }
- method flat() { nqp::p6list(nqp::list(self), List, Bool::True) }
- method eager() { nqp::p6list(nqp::list(self), List, Bool::True).eager }
- method hash() { my % = self }
+ method list() {
+ nqp::p6list(
+ self.DEFINITE ?? nqp::list(self) !! nqp::list(), List, Mu
+ );
+ }
+ method flat() {
+ nqp::p6list(
+ self.DEFINITE ?? nqp::list(self) !! nqp::list(), List, Bool::True
+ );
+ }
+ method eager() {
+ nqp::p6list(
+ self.DEFINITE ?? nqp::list(self) !! nqp::list(), List, Bool::True
+ ).eager;
+ }
+ method hash() {
+ my % = self.DEFINITE ?? self !! ();
+ }
# derived from .list
method elems() { self.list.elems }

0 comments on commit d12ecc5

Please sign in to comment.