Every story and comment from the Hacker News API, in a layout borrowed from 2001.
A comment on "..best direction for evolving Java is to encourage a more functional style". Parent comment
I have never done this, but for the usecase that you have mentioned, would the following work?
class Xyz { private Type type; private RetType type1MethodName(params) { // Do Whatever } private RetType type2MethodName(params) { // Do Whatever } public Xyz(type) { this.type = type; } public RetType methodName(params) { switch(type) { type1: return type1MethodName(params); type2: return type2MethodName(params); } } public enum Type { type1; type2; } }
There are no comments on this comment yet.
I have never done this, but for the usecase that you have mentioned, would the following work?
And then when we want to pass methods according to types, we can just instantiate the class with a proper type and pass it.