Android App Development
iOS App Development
Flutter App Development
Cross Platform App Development
Hire on-demand project developers and turn your idea into working reality.
Big thanks to Webkul and his team for helping get Opencart 3.0.3.7 release ready!
Deniel Kerr
Founder. Opencart
Top Partners
Updated 29 July 2021
According to Apple:
A collection containing the same elements as a Base collection, but on which some operations such as map and filter are implemented lazily
Lazy collections are used to compute a collection lazily i.e compute value when requested. It will helps in getting rid of intermediate array creation.
In the above playground example as you can see there are 2 same sets of operations are happing on the list. But there is one minor difference i.e on the 2nd list we are using the lazy property. It helps in reducing the computation time significantly. The lazy property is a LazySequence<T> type. The LazySequence contains the same element as the sequence. But on this, some operations such as map and filter are implemented lazily.
lazy
LazySequence<T>
LazySequence
map
filter
Now as you have seen lazy property performance, let’s talk about its limitations:
The output of this is not stored in the array. Hence all these modifiers will execute for each and every request.
Do not use lazy property every time when you use a collection. For example, if your collection contains 10 items then there is no need for you to applying lazy property. As there will be no performance gain for this case.
Thank you for reading this article. If you want to read more articles regarding iOS Development click here. And if you want to know more about lazy collection then click here.
Your email address will not be published. Required fields are marked*
Name*
Email*
Save my name email and website in this browser for the next time I comment.
Be the first to comment.
We use cookies to personalize your experience. By continuing to visit this website you agree to our use of cookies. Learn more about privacy policy
Name
Email
Subject
Enquiry or Requirement
If you have more details or questions, you can reply to the received confirmation email.