Groovy 2.5.0 adds several methods to make working with Java 8 Streams more groovy. First, the methods toList
and toSet
are added to the Stream
class. These methods will convert the stream to a List
and Set
, using the Stream.collect
method with Collectors.toList
and Collectors.toSet
as the argument. Furthermore, we can convert any array object to a Stream
using the stream
method that is added to all array objects.
In the following example, we use the support of converting an array to a Stream
and then getting a List
and Set
from the stream:
Laisser un commentaire
Participez-vous à la discussion?N'hésitez pas à contribuer!