dierre
03/06/2018, 9:23 AMNoSuchElementException. I found that I can obtain what I want using filter and then checking against list size. I was expecting to return a `T?`(meaning an optional of some kind) instead of T. So basically instead of doing list.first({p -> predicate}).orElse(defaultObject) I have to do something like var result = list.filter({p -> predicate}); if(result.isEmpty()) return defaultObject else result.first(). Do you think there is a better approach?spand
03/06/2018, 9:26 AMfirstOrNull() instead of first()spand
03/06/2018, 9:27 AMlist.firstOrNull { pred(it) } ?: defaultObjectdierre
03/06/2018, 9:28 AM