# Variadic if-else?

**URL:** <https://forum.xod.io/t/variadic-if-else/578>\
**Category:** Uncategorized\
**Created:** [March 16, 2018, 5:31pm UTC](https://forum.xod.io/t/variadic-if-else/578 "2018-03-16T17:31:37Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![gweimer](https://avatars.discourse-cdn.com/v4/letter/g/a9adbd/32.png) [@gweimer](https://forum.xod.io/u/gweimer)\
**Post date:** [March 16, 2018, 5:31pm UTC](https://forum.xod.io/t/variadic-if-else/578/1 "2018-03-16T17:31:37Z")

</div>

Easy to do…is it a good idea?

The C++ code is identical to existing if-else.  
The down-side is the order of pins needs to be kind of funky to work with variadic-2.

It will return the T of the right-most true COND, or F if none are true.

![image](https://canada1.discourse-cdn.com/flex027/uploads/xod/original/1X/5c0073672c4d06773241afa63106c6a5103d519c.png)

---

<div class="post-metadata">

**Author:** ![nkrkv](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.xod.io/nkrkv/32/8_2.png) [@nkrkv](https://forum.xod.io/u/nkrkv)\
**Post date:** [March 16, 2018, 9:29pm UTC](https://forum.xod.io/t/variadic-if-else/578/2 "2018-03-16T21:29:25Z")

</div>

Oh! Interesting use case. It’s a kind of nested ternary in conventional programming language:

```auto
const howMany =
  (x > 2000) ? "thousands" :
  (x > 200) ? "hundreds" :
  (x > 24) ? "dozens" :
  "several";

```

Would be nice if you publish a library with it, so that one can feel how convenient it is.

There’s still a TODO-feature with variadics: something like a `variadic-bypass` marker which would allow composing a new variadic node out of existing variadics and rearrange or hide terminal as desired. It should make possible creating, e.g., `average` node or your proposal with the “right” pin order.

---

<div class="post-metadata">

**Author:** ![gweimer](https://avatars.discourse-cdn.com/v4/letter/g/a9adbd/32.png) [@gweimer](https://forum.xod.io/u/gweimer)\
**Post date:** [March 16, 2018, 11:05pm UTC](https://forum.xod.io/t/variadic-if-else/578/3 "2018-03-16T23:05:04Z")

</div>

gweimer/utils now includes if-else-v & if-else-v-string (variadic version of original)
