Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Combine filter and map in Xtend collections

Tags:

xtend

Given some iterable variable v and a type T I often find myself writing code such as

v.filter[it instanceof T].map[it as T]

Does there exist some helper which does the same functionality in a single step?

like image 592
Mathias Soeken Avatar asked Feb 16 '23 20:02

Mathias Soeken


1 Answers

You may want to use v.filter(T) (or the legacy syntax v.filter(typeof(T))) which is Xtend's syntax for the Java equivalent v.filter(T.class).

like image 120
Sebastian Zarnekow Avatar answered Feb 22 '23 23:02

Sebastian Zarnekow