xii
07/17/2020, 5:47 PMxii
07/17/2020, 5:48 PMfunction foo() = if (condition) foo.filter{} else foo
xii
07/17/2020, 5:49 PMpedro
07/17/2020, 5:53 PMfoo.takeIf { !condition } ?: foo.filter{...}
Nir
07/17/2020, 5:55 PMNir
07/17/2020, 5:56 PMpedro
07/17/2020, 5:56 PM{ }
around it.
but it doesn’t look great, at least in this small example
(updated the code example)xii
07/17/2020, 5:57 PMxii
07/17/2020, 5:57 PMNir
07/17/2020, 5:57 PMNir
07/17/2020, 5:57 PMNir
07/17/2020, 5:57 PMpedro
07/17/2020, 5:58 PMtakeIf
, I think I end up undoing it. Partly because it’s not a common construct so present/future readers would find it a bit awkward to understandNir
07/17/2020, 6:01 PMNir
07/17/2020, 6:01 PMTim VanFosson
07/17/2020, 6:01 PMtakeIf
I would not make this replacement.Nir
07/17/2020, 6:02 PMNir
07/17/2020, 6:03 PMTim VanFosson
07/17/2020, 6:04 PMfoo
is therefore some type of collectionxii
07/17/2020, 6:11 PMKroppeb
07/17/2020, 7:31 PMif
is preferedArkadii Ivanov
07/17/2020, 10:45 PMfoo.takeIf { condition }?.filter {} ?: foo
Nir
07/17/2020, 11:18 PMNir
07/17/2020, 11:19 PMTim VanFosson
07/18/2020, 1:32 PMtakeWhile