how can I pass argument (names) to a function factory?
问题 I need to build a lot of functions with lots of different arguments, though they otherwise share a lot of code and structure. To avoid duplication, I thought I'd be clever and build myself a function factory (aka closure). I can't figure out how to pass the function arguments inside the function factory . My use case is a bunch of S3 constructor functions, all of which share the same validation mechanism. So I'll use that as an example to explain my problem. Say, I have a ClassA and ClassB ,