# Create callback

**URL:** <https://discourse.processing.org/t/create-callback/9831>\
**Category:** Coding Questions\
**Created:** [April 1, 2019, 10:20am UTC](https://discourse.processing.org/t/create-callback/9831 "2019-04-01T10:20:46Z")\
**Posts on this page:** 4\
**Page:** 2

<div class="post-metadata">

**Author:** ![Stanlepunk](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/stanlepunk/32/11509_2.png) [@Stanlepunk](https://discourse.processing.org/u/Stanlepunk)\
**Post date:** [April 5, 2019, 12:08pm UTC](https://discourse.processing.org/t/create-callback/9831/21 "2019-04-05T12:08:30Z")

</div>

Thks for the pro-tips, very helpful, comparing with `toString()`and `getParameterTypes()`.

But about comparaison, i’m not sure I can in my case to use it by your way.  
In this case when I call method from `void method(String name, PApplet pa, Object... args)` it not a method, so i cannot compare with a method except if create this one.

> [@GoToLoop](#):
>
> If you need to know whether 2 Method objects represent the same actual method, just call **toString()** on both objects and compare them using **equals()**.

---

<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:** [April 5, 2019, 12:13pm UTC](https://discourse.processing.org/t/create-callback/9831/22 "2019-04-05T12:13:30Z")

</div>

> [@Stanlepunk](#):
>
> Thks for the pro-tips, very helpful, comparing with `toString()` and `getParameterTypes()` .

I’ve just changed that to simply use **equals()**. **toString()** isn’t necessary after all! 🤑

> [@Stanlepunk](#):
>
> , so i cannot compare with a method except if create this one.

Indeed! But you can still create a Method just to check whether it’s the same you already have, then discard it if it is so. 🗑

---

<div class="post-metadata">

**Author:** ![Stanlepunk](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/stanlepunk/32/11509_2.png) [@Stanlepunk](https://discourse.processing.org/u/Stanlepunk)\
**Post date:** [April 5, 2019, 12:16pm UTC](https://discourse.processing.org/t/create-callback/9831/23 "2019-04-05T12:16:17Z")

</div>

> [@GoToLoop](#):
>
> Indeed! But you can still create a Method just to check whether it’s the same you already have, then discard it if it is so

it’s an option, just know which is a faster way for CPU ?

---

<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:** [April 5, 2019, 12:28pm UTC](https://discourse.processing.org/t/create-callback/9831/24 "2019-04-05T12:28:25Z")

</div>

> [@Stanlepunk](#):
>
> It’s an option, just know which is a faster way for CPU?

Your existing check algorithm is already complex anyways. 😶

My guess is that using **Class::getMethod()** and then iterating over your stored Method objects calling **equals()** won’t be any slower than what you’ve already got. 🤔

And add to that the bonus of significantly cutting off a lot of the size of your big code. 💇‍♂️

[Previous page](https://discourse.processing.org/t/create-callback/9831.md?page=1)
