0
更簡單的方法是什麼?從嵌套屬性獲取總和的更方便的方法
def totalSightings=0;
year.months.each{month->
month.weeks.each{week->
week.days.each{day->
total+=day.sightings;
}
}
}
更簡單的方法是什麼?從嵌套屬性獲取總和的更方便的方法
def totalSightings=0;
year.months.each{month->
month.weeks.each{week->
week.days.each{day->
total+=day.sightings;
}
}
}
year.months.weeks.days.sightings.flatten().sum()
呼啊。謝謝。 – user2782001