diff --git a/Tests/Unit/EnumerableTest.php b/Tests/Unit/EnumerableTest.php index ff64ed3..de1b89b 100644 --- a/Tests/Unit/EnumerableTest.php +++ b/Tests/Unit/EnumerableTest.php @@ -2533,6 +2533,9 @@ function testToString () $this->assertEquals( '123', E::from([ 1, 'a' => 2, 3 ])->toString()); + $this->assertEquals( + '123', + E::from([ [ 0, 1 ], [ 0, 2 ], [ 1, 3 ] ])->select('$v[1]', '$v[0]')->toString()); // toString (separator) $this->assertEquals( @@ -2544,6 +2547,9 @@ function testToString () $this->assertEquals( '1, 2, 3', E::from([ 1, 'a' => 2, 3 ])->toString(', ')); + $this->assertEquals( + '1, 2, 3', + E::from([ [ 0, 1 ], [ 0, 2 ], [ 1, 3 ] ])->select('$v[1]', '$v[0]')->toString(', ')); // toString (separator, selector) $this->assertEquals( @@ -2555,6 +2561,9 @@ function testToString () $this->assertEquals( '0=1, a=2, 1=3', E::from([ 1, 'a' => 2, 3 ])->toString(', ', '"$k=$v"')); + $this->assertEquals( + '0=1, 0=2, 1=3', + E::from([ [ 0, 1 ], [ 0, 2 ], [ 1, 3 ] ])->select('$v[1]', '$v[0]')->toString(', ', '"$k=$v"')); } #endregion diff --git a/YaLinqo/Enumerable.php b/YaLinqo/Enumerable.php index 119f348..4c31d20 100644 --- a/YaLinqo/Enumerable.php +++ b/YaLinqo/Enumerable.php @@ -1021,7 +1021,7 @@ public function toObject ($propertySelector = null, $valueSelector = null) public function toString ($separator = '', $valueSelector = null) { $valueSelector = Utils::createLambda($valueSelector, 'v,k', false); - $array = $valueSelector ? $this->select($valueSelector)->toArray() : $this->toArray(); + $array = $valueSelector ? $this->select($valueSelector)->toList() : $this->toList(); return implode($separator, $array); }