'>' replaces a PriorityQueue or a JSON array too, and the queue keeps its size limit
The complete source of streamsAndPipelines_sink_queue_and_json.ek9, compiled by the EK9 compiler. Shown on streamsAndPipelines.html.
#!ek9 defines module site.streamsAndPipelines.sink.queue.and.json defines program SinkQueueAndJsonDemo() stdout <- Stdout() topTwo <- (PriorityQueue() of Integer).withSize(2) topTwo += 100 cat [4, 8, 6] > topTwo stdout.println(`queue after >: ${topTwo.list()}`) cat [9] >> topTwo stdout.println(`queue after >>: ${topTwo.list()}`) numbers <- JSON().array() cat [JSON(1), JSON(2)] >> numbers cat [JSON(3)] > numbers stdout.println(`array after >: ${numbers}`) cat [JSON(4)] >> numbers stdout.println(`array after >>: ${numbers}`)
Download streamsAndPipelines_sink_queue_and_json.ek9
Output
queue after >: [8, 6] queue after >>: [9, 8] array after >: [3] array after >>: [3,4]