ListtNil works nicely with function based on Iterator
authorwidmogrod <widmogrod@gmail.com>
Wed, 13 Jun 2018 21:06:54 +0000 (23:06 +0200)
committerwidmogrod <widmogrod@gmail.com>
Wed, 13 Jun 2018 21:06:54 +0000 (23:06 +0200)
src/Primitive/ListtNil.php

index c2a4c00..21bb8ec 100644 (file)
@@ -4,10 +4,10 @@ declare(strict_types=1);
 
 namespace Widmogrod\Primitive;
 
-use Widmogrod\Common;
 use FunctionalPHP\FantasyLand;
+use Widmogrod\Common;
 
-class ListtNil implements Listt
+class ListtNil implements Listt, \IteratorAggregate
 {
     use Common\PointedTrait;
 
@@ -123,4 +123,12 @@ class ListtNil implements Listt
     {
         throw new EmptyListError(__FUNCTION__);
     }
+
+    /**
+     * @inheritdoc
+     */
+    public function getIterator()
+    {
+        return new \ArrayObject();
+    }
 }