top | item 7588533 (no title) yeahbutbut | 12 years ago And so far everyone has missed telling the poor OP how to avoid writing two equality checks... if( [80, 443].indexOf(port) !== -1 && http === false ) discuss order hn newest skrebbel|12 years ago Are you certain that that's an improvement? yeahbutbut|12 years ago For two options, almost certainly not ;-)For N ports, or for a port list defined from a config file however it could be. It's even nicer in python: ports = [80, 443, ...] if port in ports and http: ... Or with underscore: var ports = [80, 443, ...]; if(_(ports).contains(port) && http) { ... } Good collections make it better than manually checking the return code or checking an explicit set of port values. Also configuration > magic_nums. cwmma|12 years ago If( ~[80, 443].indexOf(port) && http=== false)
skrebbel|12 years ago Are you certain that that's an improvement? yeahbutbut|12 years ago For two options, almost certainly not ;-)For N ports, or for a port list defined from a config file however it could be. It's even nicer in python: ports = [80, 443, ...] if port in ports and http: ... Or with underscore: var ports = [80, 443, ...]; if(_(ports).contains(port) && http) { ... } Good collections make it better than manually checking the return code or checking an explicit set of port values. Also configuration > magic_nums.
yeahbutbut|12 years ago For two options, almost certainly not ;-)For N ports, or for a port list defined from a config file however it could be. It's even nicer in python: ports = [80, 443, ...] if port in ports and http: ... Or with underscore: var ports = [80, 443, ...]; if(_(ports).contains(port) && http) { ... } Good collections make it better than manually checking the return code or checking an explicit set of port values. Also configuration > magic_nums.
skrebbel|12 years ago
yeahbutbut|12 years ago
For N ports, or for a port list defined from a config file however it could be. It's even nicer in python:
Or with underscore: Good collections make it better than manually checking the return code or checking an explicit set of port values. Also configuration > magic_nums.cwmma|12 years ago