Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. COI know how erasure works yes, although the generated code is a little more complex than that. I've pondered a method like that already, but isInstance is not a very good check, I am more after Class.isAssignableFrom(cls). It's not as elegant as I'd like it but it is one of the ways I can get the assertion in place. I could always have both options, with a disclaimer. It would be easier to use the simple option for simple situations with a predictable datatype, and then the stronger option for the truly dynamic case. It could be made easier to not ask for the class, but just an example
      singulars
    2. COThe more I think about it the more this seems like the safest solution. I'm sure I can find a way to deal with the extra complexity. The more convincing point is that this is the method used for a lot of the other collections libraries, suggesting there isn't a cleaner or nicer method. If you want to be able to enforce the type you need to get it from somewhere.
      singulars
    3. COFrom my experience, even though the JVM doesn't do a check at the point of source-explicit cast, it will still do a check when you try assigning the result of the generified method to a variable of the expected type (and I actually find that to be a bit better in most cases than having the exception being thrown within the `getValue()` method, as in cases like that it's normally an issue with the code at the point of method call rather than anything in the `getValue()` method itself, so having the topmost item in the stacktrace being the line where the method is called makes more sense to me).
      singulars
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload