Page History
...
우리는 위와같이 복잡한 스트림처리를 단순화하기위해 스트림의 결합요소에대해조금더 연구해보겠습니다.결합요소에 대해 더 연구해보겠습니다.
다양한 소스/싱크처리
Code Block | ||||
---|---|---|---|---|
| ||||
// Create a source from an Iterable
Source.From(new List<int> {1, 2, 3});
// Create a source from a Task
Source.FromTask(Task.FromResult("Hello Streams!"));
// Create a source from a single element
Source.Single("only one element")
// an empty source
Source.Empty<int>();
// Sink that aggregates over the stream and returns a Task
// of the final result as its materialized value
Sink.Aggregate<int, int>(0, (sum, i) => sum + i);
// Sink that returns a Task as its materialized value,
// containing the first element of the stream
Sink.First<int>();
// A Sink that consumes a stream without doing anything with the elements
Sink.Ignore<int>();
// A Sink that executes a side-effecting call for every element of the stream
Sink.ForEach<string>(Console.WriteLine); |