April 20, 201510 yr Beginners swag. public static int getMyTotalLevel(Script script) { int total = 0; for (Skill skill : Skill.values()) total += script.getSkills().getStatic(skill); return total; }
April 27, 201510 yr Could always use Streams introduced in Java 8 to make this a one liner. public static int getMyTotalLevel(Script script) { return Arrays.stream(Skill.values()).mapToInt(script.getSkills()::getStatic).sum(); }
April 27, 201510 yr Author Could always use Streams introduced in Java 8 to make this a one liner. public static int getMyTotalLevel(Script script) { return Arrays.stream(Skill.values()).mapToInt(script.getSkills()::getStatic).sum(); } Not sure if it's worth it but sure.
Create an account or sign in to comment