Feature: firstOrElse variant in List #37372
Labels
area-core-library
SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries.
library-core
type-enhancement
A request for a change that isn't a bug
It would be convinient to have variation of first property as method that would allow something to get first element, or produce default value insteaf of throwing wrong state exception..
Right now I am doing something like this (to avoid extra var)
var val=myList.where((i)=>i.x>5).map((i)=>i.y).firstWhere((v)=>true), orElse:()=>someDefaultValue
while I would like to terminate like this:
var val=myList.where((i)=>i.x>5).map((i)=>i.y).firstOrElse(()=>defaultValue);
The text was updated successfully, but these errors were encountered: