# Add several values to IntList

**URL:** <https://discourse.processing.org/t/add-several-values-to-intlist/4779>\
**Category:** Coding Questions\
**Created:** [October 23, 2018, 2:28pm UTC](https://discourse.processing.org/t/add-several-values-to-intlist/4779 "2018-10-23T14:28:56Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![flashbacker](https://avatars.discourse-cdn.com/v4/letter/f/a183cd/32.png) [@flashbacker](https://discourse.processing.org/u/flashbacker)\
**Post date:** [October 23, 2018, 2:28pm UTC](https://discourse.processing.org/t/add-several-values-to-intlist/4779/1 "2018-10-23T14:28:56Z")

</div>

Hi,

I’m starting to use IntList in a project, not absolutely comfortable with everything yet…  
I’m seeing in [the documentation](https://processing.org/reference/IntList_append_.html) that I can add several int at once with myList.append(values) or myList.append(list) but each time i’m trying to add something more than a single integer, i’m getting this error:

```auto
the function "append()" expects parameters like: "append(int)"

```

Does any body have some experience with this?

thanks!

---

<div class="post-metadata">

**Author:** ![hamoid](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/hamoid/32/58_2.png) [@hamoid](https://discourse.processing.org/u/hamoid)\
**Post date:** [October 23, 2018, 2:35pm UTC](https://discourse.processing.org/t/add-several-values-to-intlist/4779/2 "2018-10-23T14:35:06Z")

</div>

Hi! Like this:

```auto
IntList inventory = new IntList();
inventory.append(1);
inventory.append(new int[] {2, 3, 4});

```

---

<div class="post-metadata">

**Author:** ![flashbacker](https://avatars.discourse-cdn.com/v4/letter/f/a183cd/32.png) [@flashbacker](https://discourse.processing.org/u/flashbacker)\
**Post date:** [October 23, 2018, 2:39pm UTC](https://discourse.processing.org/t/add-several-values-to-intlist/4779/3 "2018-10-23T14:39:55Z")

</div>

@hamoid thanks a lot ! Among all the things I’ve tried I don’t think I would ever find this one by myself!

Thanks again

---

<div class="post-metadata">

**Author:** ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)\
**Post date:** [October 23, 2018, 2:42pm UTC](https://discourse.processing.org/t/add-several-values-to-intlist/4779/4 "2018-10-23T14:42:40Z")

</div>

Indeed there’s no explanation whatsoever about what `.append(values)` and `.append(list)` arguments actually mean! 👎

I had to look at the source code in order to know all of its overloaded signatures: 🙄

> <https://github.com/processing/processing/blob/processing-0265-3.4/core/src/processing/data/IntList.java#L274-L293>

```java
final IntList vals = new IntList();

vals.append(0);
println(vals);

vals.append(new int[] { 84, 15, 102 });
println(vals);

vals.append(new IntList( -5, 11 ));
println(vals);

exit();

```

---

<div class="post-metadata">

**Author:** ![flashbacker](https://avatars.discourse-cdn.com/v4/letter/f/a183cd/32.png) [@flashbacker](https://discourse.processing.org/u/flashbacker)\
**Post date:** [October 23, 2018, 2:52pm UTC](https://discourse.processing.org/t/add-several-values-to-intlist/4779/5 "2018-10-23T14:52:20Z")

</div>

Indeed a good way to proceed!  
I’ll keep that in mind a try to dig myself in the source code next time i’m facing that problem! 👍

---

<div class="post-metadata">

**Author:** ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)\
**Post date:** [October 23, 2018, 2:59pm UTC](https://discourse.processing.org/t/add-several-values-to-intlist/4779/6 "2018-10-23T14:59:06Z")

</div>

Also, it’s a pity we need to create a whole array in order to pass multiple values to **append()**.  
`vals.append(new int[] { 84, 15, 102 });`

Funny, IntList’s constructor is overloaded to do just that:  
`vals.append(new IntList( -5, 11 ));`

By just changing `public void append(int[] values) {` to `public void append(int... values) {`, we could invoke it like this:  
`vals.append( 84, 15, 102 );`

---

<div class="post-metadata">

**Author:** ![Lexyth](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/lexyth/32/7403_2.png) [@Lexyth](https://discourse.processing.org/u/Lexyth)\
**Post date:** [October 23, 2018, 3:05pm UTC](https://discourse.processing.org/t/add-several-values-to-intlist/4779/7 "2018-10-23T15:05:38Z")

</div>

Finally i get the difference between [] and … . I looked some Time ago for Hours, only to get told that they are both the Same… had to work with hashmaps in an old project to get that functionality…

---

<div class="post-metadata">

**Author:** ![hamoid](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/hamoid/32/58_2.png) [@hamoid](https://discourse.processing.org/u/hamoid)\
**Post date:** [October 23, 2018, 3:08pm UTC](https://discourse.processing.org/t/add-several-values-to-intlist/4779/8 "2018-10-23T15:08:55Z")

</div>

The autocomplete in IntelliJ Idea told me…  
 ![Screenshot%20from%202018-10-23%2017-04-37](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/2/2f1f22413743242903116cd1884b9b43ca25803b.png) ![Screenshot%20from%202018-10-23%2017-04-13](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/e/e90be6005d03f9807d8235b3ea6f9a2804322bff.png)

---

<div class="post-metadata">

**Author:** ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)\
**Post date:** [October 23, 2018, 3:11pm UTC](https://discourse.processing.org/t/add-several-values-to-intlist/4779/9 "2018-10-23T15:11:41Z")

</div>

AFAIK, variadic parameters exist in Java since version 5. ☕

IMO, it’s a huge oversight that Processing’s source code don’t use such ancient feature in as many places as possible! 👁

Java is already version 11 now! 😳
