ouch.. true! if so: list ? list.first() : defaultValue
p On Thu, Oct 18, 2018 at 7:07 PM ocs@ocs <o...@ocs.cz> wrote: > Myself, I am not a huge fan of adding not-often-needed functionalities > (and actually would add almost none of those discussed lately); > nevertheless... > > On 18 Oct 2018, at 6:48 PM, Paolo Di Tommaso <paolo.ditomm...@gmail.com> > wrote: > > -1, it can be easily done as: > list.first() ?: defaultValue > > > ... this won't work in case the first object is a Groovy False (e.g., an > empty string, or a plethora of others). > > All the best, > OC > > > > p > > On Thu, Oct 18, 2018 at 6:45 PM Daniel.Sun <sun...@apache.org> wrote: > >> +0 from me. >> P.S. we should add similar DGM for `last` too? >> >> Cheers, >> Daniel.Sun >> >> >> >> >> ----- >> Daniel Sun >> Apache Groovy committer >> Blog: http://blog.sunlan.me >> Twitter: @daniel_sun >> >> -- >> Sent from: http://groovy.329449.n5.nabble.com/Groovy-Dev-f372993.html >> > >