what to return from this function?
Posted: Wed Jan 20, 2010 9:35 pm
hey im prototyping some functions for working with colors and positions like hex to rgb and calculate a position on an arc and shizz and im wondering what you guys would expect as a return in this situation.
okay so you are going to take a hex rgb value and convert it to integer based rgb:
but oops you threw in an extra character by accident oh noes!
what would you expect for a return?
should i throw an exception? return NaN? false? null?
not sure if there is really a right answer but lets say you are debugging this when you didn't write it. what would be least annoying?
okay so you are going to take a hex rgb value and convert it to integer based rgb:
Code: Select all
ohbaby = 'a33445'.toRgb();
Code: Select all
ohnoobaby = 'a334445'.toRgb();
should i throw an exception? return NaN? false? null?
not sure if there is really a right answer but lets say you are debugging this when you didn't write it. what would be least annoying?