# Functions argument

**URL:** <https://discourse.processing.org/t/functions-argument/11010>\
**Category:** Beginners\
**Created:** [May 7, 2019, 8:34pm UTC](https://discourse.processing.org/t/functions-argument/11010 "2019-05-07T20:34:01Z")\
**Posts on this page:** 1\
**Showing post:** 5

<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:** [May 9, 2019, 12:42pm UTC](https://discourse.processing.org/t/functions-argument/11010/5 "2019-05-09T12:42:05Z")

</div>

> [@raron](#):
>
> You could also use a `class` kind of like a `struct`.

Or even better, use it as an actual full-fledged `class`, w/ constructors, fields & methods: 😤

```auto
// https://Discourse.Processing.org/t/functions-argument/11010/5
// GoToLoop (v1.1) (2019/May/09)

final Pair pair = new Pair(5, -10);

void setup() {
  println(pair); // [5, -10]
  println(pair.calc('y')); // [-50, 540]
  println(pair.set(5, -10)); // [5, -10]
  println(pair.calc('u')); // [3, -2]
  println(pair.clone()); // [3, -2]
  exit();
}

static final class Pair implements Cloneable {
  int a, b;

  Pair() {
  }

  Pair(final int a, final int b) {
    set(a, b);
  }

  Pair set(final int aa, final int bb) {
    a = aa;
    b = bb;
    return this;
  }

  Pair calc(final char ch) {
    if (ch == 'y') {
      a *= b;
      b = (a + 5) * (b - 2);
    } else {
      b /= a;
      a += b;
    }
    return this;
  }

  @Override Pair clone() {
    try {
      return (Pair) super.clone();
    }
    catch (final CloneNotSupportedException e) {
      throw new RuntimeException(e);
    }
  }

  @Override String toString() {
    return "[" + a + ", " + b + "]";
  }
}

```

---

_[View the full topic](https://discourse.processing.org/t/functions-argument/11010)._
