.remove()
Anonymous contributor
Published May 22, 2024
Contribute to Docs
The .remove()
method in Dart is used to remove the first occurrence of a specified element from a queue if it exists.
Syntax
void remove(Object? value)
value
: The element to be removed from the queue.
Example
In the following example, the element 3
is removed from the queue using the .remove()
method:
import 'dart:collection';void main() {// Creating a queueQueue<int> queue = Queue.from([1, 2, 3, 4, 5]);// Outputting the original queueprint('Original Queue: $queue');// Removing an element from the queuequeue.remove(3);// Outputting the modified queueprint('Modified Queue: $queue');}
The above code results in the following output:
Original Queue: {1, 2, 3, 4, 5}Modified Queue: {1, 2, 4, 5}
All contributors
- Anonymous contributor
Contribute to Docs
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.