in reply to Distiguishing arguments: number-strings vs real integer
I want to find out if a function is called with an integer or a string containing an integer.
The best solution is to stop wanting that.
Generally speaking, a function which expects a number shouldn't care whether the number was supplied as a string or not, and a function which expects a string shouldn't care if you neglected to wrap a numeric-looking string in the proper quote marks.
If your function can be given either a number or a string and is supposed to do different things with each, consider rewriting it into two different functions, so the caller can choose which behaviour they want.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Distiguishing arguments: number-strings vs real integer
by LanX (Saint) on Aug 10, 2018 at 15:23 UTC | |
by choroba (Cardinal) on Aug 10, 2018 at 15:28 UTC | |
by LanX (Saint) on Aug 10, 2018 at 15:35 UTC |