Skip to content

Conversation

@joente
Copy link
Member

@joente joente commented Sep 4, 2025

Description

To reduce size, it can be useful to not return nil values. For example, support type T has a property with definition str? and this property is nil most of the time, you might save bandwidth to not include the value when nil.

This pull request adds the ? prefix flag which tells to exclude from a result when nil.

Example:

set_type('A', {
    name: 'str',
    description: 'str?',  // will return when nil
});
set_type('B', {
    name: 'str',
    description: '?str?',  // do not return when nil
});

[A{name: 'a'}.wrap(), B{name: 'a'}.wrap()];

Returns:

[
    {
        "description": null,
        "name": "a"
    },
    {
        "name": "a"
    }
]

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

  • Test wrap contains the test code

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • New and existing unit tests pass locally with my changes

@joente joente self-assigned this Sep 4, 2025
@joente joente merged commit 3d24dca into main Sep 4, 2025
1 check passed
@joente joente deleted the skip-nil branch October 25, 2025 14:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants