daniel_sun
03/01/2024, 12:53 AMsolvingj
03/01/2024, 4:14 AMsolvingj
03/01/2024, 4:15 AMsolvingj
03/01/2024, 4:16 AMlist
can be null, but that can be handled with elvis:
list ?: list
.takeWhile{ it.someCondition()}?
.collect {it.someField()}?
.findAll{ it.someCondition{}}
solvingj
03/01/2024, 4:16 AMblackdrag
03/01/2024, 8:40 AM?.
they just have to stay together. You can have list ?.
on one line and takeWhile on the next.solvingj
03/03/2024, 1:54 AM"takeUntil"
which takes all elements from a collection but stops when the predicate is true. I thought of some hacks to do it. I guess the most concise is: list.reverse().dropWhile{!predicate}.reverse()
but it feels like there might be something first class i’m missing.paulk_asert
03/03/2024, 8:20 AMlist.takeWhile{ predicate }
? You'd normally negate the predicate but you have already done that in your workaround?solvingj
03/03/2024, 12:54 PMsolvingj
03/03/2024, 12:57 PMsolvingj
03/03/2024, 1:03 PMfindIndexOf { predicate }
and then subList(0, index + 1)
and all thatsolvingj
03/03/2024, 1:16 PMsum()
return Object
and not infer the return type is the same as the input type, and take a generic parameter for the overload which takes the custom closure?paulk_asert
03/03/2024, 2:31 PMassert '123' == [1, 2, 3].sum('')
But we probably could have done smarter generics for the no initial value case if we assume that we will only ever deal with objects in our aggregates which have types which are closed under plus.bsdooby
03/04/2024, 8:27 AMtrait
w/ @CompileStatic
, a reference to "${this}"
is working, but not "${this.y()}"
(given that my record type as a member called y
). If I omit the static compile annotation, then it works...Why is this so?solvingj
03/05/2024, 3:16 PMgrep
?solvingj
03/05/2024, 3:17 PMGroovy Duke
03/05/2024, 3:29 PMgrep
. I doubt many others have either, but it might become popular on Google for a second because of your question.Groovy Duke
03/05/2024, 10:54 PM@AnnotationCollector
and a processor. Does the processor need to be precompiled because all I get is the following error when I try to debug using a remote debugger and I never get to the processor:
BUG! exception in phase 'semantic analysis' in source unit '/.../SomeController.groovy' Index 0 out of bounds for length 0
Suresh
03/07/2024, 3:34 PMbsdooby
03/09/2024, 4:28 PM@CompileStatic
does not allow the following:
//@CompileStatic
trait Printable {
def printMe() {
println "${x} ${y} ${z}";
}
}
bsdooby
03/09/2024, 4:31 PMetxaleku
03/15/2024, 9:14 PMpaulk_asert
03/15/2024, 9:19 PMetxaleku
03/15/2024, 9:47 PMetxaleku
03/15/2024, 9:55 PMInternal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator at <mailto:admin@groovy-lang.org|admin@groovy-lang.org> to inform them of the time this error occurred, and the actions you performed just before this error.
More information about this error may be available in the server error log.
Apache/2.4.29 (Ubuntu) Server at <http://groovy-lang.org|groovy-lang.org> Port 80
paulk_asert
03/16/2024, 9:49 AMetxaleku
03/22/2024, 5:00 PMetxaleku
03/22/2024, 5:03 PMpaulk_asert
03/23/2024, 8:57 AMetxaleku
03/25/2024, 4:27 PM