Hi, I find that the Day
class code:
enum Day {
monday,
tuesday,
wednesday,
thursday,
friday,
saturday,
sunday;
Day operator +(int days) {
final numberOfItems = Day.values.length;
final index = (this.index + days) % numberOfItems;
return Day.values[index];
}
}
Instead of using Day.values
, I find that I can use values
directly. I think this make the code more concise and easy to maintain. Because if you later change the name of Day enum, you don’t need to change xxx.values inside.