ile(){}while(){}while(){}while(){}while(){}w {}while(){}while(){}while(){}while(){}while(){}w 都什麼時代了 你還在寫 while loop 嗎? INFECTED PROGRAM WHILE LOOP @pishen
:+ dates.last.plusDays(1) } println(dates) dates.length == x dates.length == x + 1 An optional part of code that *will* change the program's behavior. ?
:+ dates.last.plusDays(1)) } else { dates } } val dates = iterate(List(startDate)) println(dates) return You don't have to write "return" in Scala's function.
:+ dates.last.plusDays(1)) } else { dates } } Tail Recursion Only call yourself at the last position. Tail Call Optimization Prevent memory from stack overflow. https://en.wikipedia.org/wiki/Tail_call https://www.artima.com/pins1ed/functions-and-closures.html#8.9 Not available in Java ⚠
val hasNext: Boolean = page.hasNextPage() val nextPage: Page = page.getNextPage() May return null if Page doesn't exist. Given a number n, please return first n items to me?