# ReplaceByCondition not working on empty list

**URL:** <https://forum.dynamobim.com/t/replacebycondition-not-working-on-empty-list/56254>\
**Category:** Lists-Logic\
**Created:** [October 15, 2020, 11:22pm UTC](https://forum.dynamobim.com/t/replacebycondition-not-working-on-empty-list/56254 "2020-10-15T23:22:09Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Paul\_Wintour](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/paul_wintour/32/9381_2.png) [@Paul\_Wintour](https://forum.dynamobim.com/u/Paul_Wintour)\
**Post date:** [October 15, 2020, 11:22pm UTC](https://forum.dynamobim.com/t/replacebycondition-not-working-on-empty-list/56254/1 "2020-10-15T23:22:09Z")

</div>

Hi

Can someone explain why the ‘ReplaceByCondition’ node wouldn’t be working on an empty list? Even Clockwork’s ‘List.ReplaceEmptyLists’ is not working as expected. I simply want a conditional statement to replace an empty list with ‘0’.

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/6/2/628267ba9dc562a886d202e1840663fc323ceeb9.jpeg)

[emptyLists.dyn](https://forum.dynamobim.com/uploads/short-url/jwa1WDnsmHZwrJyEWQcZk0gUDGf.dyn) (17.0 KB)

---

<div class="post-metadata">

**Author:** ![Draxl\_Andreas](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/draxl_andreas/32/145744_2.png) [@Draxl\_Andreas](https://forum.dynamobim.com/u/Draxl_Andreas)\
**Post date:** [October 16, 2020, 7:16am UTC](https://forum.dynamobim.com/t/replacebycondition-not-working-on-empty-list/56254/2 "2020-10-16T07:16:59Z")

</div>

![2020-10-16_09h12_06](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/c/8/c86a040d47f6dd5fbca1b392ab5d69f613a98828.png) ![2020-10-16_09h15_55](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/4/e/4eb9824b742b4f582bc6dd8fa620032f60a8313b.png)  
Maybe you can verify your question… hmmm

KR

Andreas

---

<div class="post-metadata">

**Author:** ![solamour](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/solamour/32/153516_2.png) [@solamour](https://forum.dynamobim.com/u/solamour)\
**Post date:** [October 16, 2020, 3:15pm UTC](https://forum.dynamobim.com/t/replacebycondition-not-working-on-empty-list/56254/3 "2020-10-16T15:15:12Z")

</div>

Hi Paul,

The out of the box node requires an applicable `Function` to be passed into the **condition** input to work. While the _List.IsEmpty_ node returns a function, its condition isn’t met as the result will be `True` or `False`, and the `List.Empty` node doesn’t return a function as it has no input ports.

To solve this now, you can either use the **Clockwork List.ReplaceEmptyLists** node or approach 🙂 Andreas’ approach is to convert first to a true/false boolean list and then replace those elements.

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/6/7/67792bf3979b4497a045a491270f6ccb0be68557.png)

---

<div class="post-metadata">

**Author:** ![Paul\_Wintour](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/paul_wintour/32/9381_2.png) [@Paul\_Wintour](https://forum.dynamobim.com/u/Paul_Wintour)\
**Post date:** [October 21, 2020, 2:58am UTC](https://forum.dynamobim.com/t/replacebycondition-not-working-on-empty-list/56254/4 "2020-10-21T02:58:14Z")

</div>

> [@solamour](#):
>
> While the _List.IsEmpty_ node returns a function, its condition isn’t met as the result will be `True` or `False` ,

You’ve lost me on this. Isn’t True/False exactly what you want there?

In any case, can this be fixed in the next release please.

---

<div class="post-metadata">

**Author:** ![Michael\_Kirschner2](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/michael_kirschner2/32/75576_2.png) [@Michael\_Kirschner2](https://forum.dynamobim.com/u/Michael_Kirschner2)\
**Post date:** [October 21, 2020, 3:05am UTC](https://forum.dynamobim.com/t/replacebycondition-not-working-on-empty-list/56254/5 "2020-10-21T03:05:15Z")

</div>

I think this doesn’t work because of replication:  
this is replace -

> <https://github.com/DynamoDS/Dynamo/blob/0cdae8c2ea797692ce25e9201c6681b1c7796673/src/Engine/ProtoCore/ExtendedLibraries/FunctionObject.ds#L233>

it takes `var` - not `var[]..[]`

an empty list has no items and my guess is that the function doesn’t get called at all since there is nothing to replicate over.

Try calling it over `[[]]` a list of an empty list.

---

<div class="post-metadata">

**Author:** ![blsalvio](https://avatars.discourse-cdn.com/v4/letter/b/ad7895/32.png) [@blsalvio](https://forum.dynamobim.com/u/blsalvio)\
**Post date:** [October 21, 2020, 3:47am UTC](https://forum.dynamobim.com/t/replacebycondition-not-working-on-empty-list/56254/6 "2020-10-21T03:47:41Z")

</div>

hi @Paul_Wintour

the reason I think it is not working is that when you use list as the item in ‘ReplaceByCondition’ node, it will compare every item in the list not the list itself so since the list you used in the item is empty, there is nothing to replace so it will just output an empty list. if you want to replace an empty list with a value you can use the following:

 ![zz](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/9/0/90bafa52390509601d69556d810c60d18ac8fac6.png)
