weird, I know a List is an Iterable, but what happ...
# questions
s
weird, I know a List is an Iterable, but what happens if you try force casting it?
Copy code
SessionItemGroup.getAll((Iterable<Long>) longIds)
t
I still get an error.
[Static type checking] - Cannot call com.hypercision.attproto.sessionitem.SessionItemGroup#getAll(java.lang.Iterable <<http://java.io|java.io>.Serializable>) with arguments [java.lang.Iterable <Long>]
m
What about
SessionItemGroup.getAll(longIds as Iterable<Serializable>)
? That seems to be what the method is expecting.
t
That worked! Thank you
👍 1
s
Yeah, meant to put Serializable instead of Long. Thanks Matthias. I know “as” works, does (casting) work without using as? I’ve encountered this behavior before but don’t remember exactly how I fixed it
m
@scott Yes, a regular cast will probably also work in this case. I have also encountered issues upgrading Groovy 3 minor versions where adding regular casts did not work whereas using
as
did, so I wanted to check that first. (Also I find it more readable)
s
I wonder if using "as" is more costly than just casting. Yes, I do believe this issue is specific to upgrading Groovy 3 to newer versions. This was not necessary in the past and I am not sure why this behavior was introduced?