-
Notifications
You must be signed in to change notification settings - Fork 307
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Request: Add Optional() function for Objects and Maps. #174
Comments
By convention map values are optional, as there are no restrictions on what the key value can be. The key error is really an access error which is what you would expect to receive in the event of a missing value. What I think would make a better approach would be a single engine function or modifying an existing one, to test for a key in a map.
@geoffjentry @cjllanwarne has there ever been any talk of including a check like this? |
I just discovered that when using a |
@rhpvorderman is this still an issue? |
Structs are implemented now, so away we go. |
The following hack allows to solve the issue without having to set null values in the JSON:
It is a little elaborate, but it basically works as a |
The following works a bit better:
|
There is actually a better way to imitate an
To imitate a |
Hi there.
I would like to request an
Optional()
function for map-like objects. If a key is not present in an object, normally a keyError returns.Optional(object.key)
will returnNone
when the key is not present. I could not find such a thing in the current WDL implementation (but I may have overlooked).That would be useful in these types of situations:
Originally (without optional) your inputs.json would look like this:
But with
Optional()
it can look like this:When there are 10 optional values, this save a lot of typing and unnecessary duplication in the JSON. Why specify all these values if they have sensible defaults? There are quite some command line tools with many optional parameters that this feature seems very useful to me. Real word example:
I happen to have some experience with programming in Scala, so if you give me some pointers, I could possibly implement this myself.
The text was updated successfully, but these errors were encountered: