The first in an ongoing series of posts to help us hold on to those things we too often forget. Today’s slippery pickle is… Argument Error: wrong number of arguments (x for y)!!!
I’ve Googled this embarassingly simple thing an embarassingly large number of times (like maybe an actual googol). Which number is the number of arguments I supplied? Which number is the number of arguments required?
Uh….
- Google it
- Get the answer
- Forget it
- Goto 1
THIS WAY LIES MADNESS
Let’s figure out a way to remember it once and for all, shall we?
BEHOLD - Alec Barkwin, Argument Error Dog
LOOK. AT. HIM.
He is not pleased with you. You supplied the wrong number of arguments…AGAIN.
Do not be afraid!
If you let them, his eyes communicate more than just displeasure; they tell you how to read the Argument Error, and how to correct it.
I know, hard to believe. But follow me, friend. Let’s look at what he says…
** What the hell did you do that for?
Who did this terrible thing?
You did.
For what reason? Alec does not know. But he does know how you should read the error:
- Argument Error: wrong number of arguments
- ([What the hell did you do that] for? [Here’s what you should have done…])
Let’s try an example:
- Argument Error: wrong number of arguments
- ([1,333,296] for [2])
Now see Alec Barkwin in your mind’s eye…and hear his voice. (My Alec Barkwin sounds like ‘Glengarry Glen Ross’ era Alec Baldwin, but YMMV)
What the hell did you provide 1,333,296 arguments for??? Oh yeah? Well I don’t care.
You go provide 2.
You get out there and provide 2 or it’s hit the bricks, pal…
Alec Barkwin is telling me so much. Sure he’s angry and he’s asking what I did that for. Maybe he thinks a loser is a loser and my ass should be fired and that coffee is for coders.
But he’s also telling me that he could go out there tonight, on tonight’s specs and turn them all green.
Can you?
Can you?
And this is how:
- Argument Error: wrong number of arguments (your number or arguments - for - correct number of arguments)
- Argument Error: wrong number of arguments (1,333,296 for 2)
- Argument Error: wrong number of arguments (what the hell did you do 1,333,296 for? Do 2, you pathetic excuse for a codesman.)
Let him guide your way.
ABC = Always Be Coding.