elementAtOrElse

This takes an index and a lambda to be executed if there's no element at the given index. The lambda will receive the index that was passed. For example, the following code will return 20, which is the index 10 that we passed times 2 – because the sequence has only eight elements:

sequence.elementAtOrElse(10, { it * 2 })
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.135.216.75