Somewhere in a prototype extension library, I noticed a shorthand (can't find it now) for testing whether an parameter is in a set of values.
 
The set was in an object or an array (don't remember) and resulted in an easy shorthand.
 
Maybe something like:
 
function myFunc (parm1) {
if( {2:2, 5:5, 9:9, 17:17}[parm1] ) { // Is parm1 equal to 2, 5, 9 or 17?
 
This seems more verbose that what I recall. 
 
What's a good shorthand technique for testing whether a value is in a set?
 
Sam
 
 
_______________________________________________
Rails-spinoffs mailing list
Rails-spinoffs@lists.rubyonrails.org
http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs

Reply via email to