Added mustGet an mustGetEntry to TypedMaped#249
Added mustGet an mustGetEntry to TypedMaped#249evaporei merged 2 commits intographprotocol:masterfrom
mustGet an mustGetEntry to TypedMaped#249Conversation
This adds two small helpers that make it easier to work with `JSONValue` so that it's possible to get elements from objects more tersely. #### Open Questions I noticed that `Entity` which extends `TypeMap` uses `get` without checking `null` and only using typing tricks to remove the nullability that `get` brings. So I'm wondering: - Should I remove the `assert` in the `must...` version - Or should we change `Entity` to now use `mustGet` instead
|
@maoueh I'm not sure I understood the type trick you've mentioned about Besides that do you have one or a few examples I'm not sure if I got it right but it seems that the |
|
Right now, here the definition of This What happen at runtime, my impression is if the variable is actually Now, about Right now, one must write something like this: This creates lots of boilerplate code while it could be terser. Now, this could be like that: But this will lead to error harder to debug IMO, because the actual error will be arise when the So I think adding Here it looks like the second snippet but is more stricter but asserting that the FutureAfter working myself with parsing JSON, I think more quality of life is necessary to make it easier to write subgraph that deals with JSON. Indeed, the actual extraction of fields to something useful contains lot of boilerplate code. I thought a little bit about that and have some ideas. |
evaporei
left a comment
There was a problem hiding this comment.
I'm approving and I agree with your comment, the only thing is that the error message has a typo doest -> doesn't.
|
Will fix of course, let's still discuss it at the meeting soon. |
|
I don't have write access to repo, so I cannot merge manually. PR is ready. |
This adds two small helpers that make it easier to work with
JSONValueso that it's possible to get elements from objects more tersely.Open Questions
I noticed that
Entitywhich extendsTypeMapusesgetwithout checkingnulland only using typing tricks to remove the nullability thatgetbrings.So I'm wondering:
assertin themust...versionEntityto now usemustGetinstead