Skip to content

Conversation

@ioquatix
Copy link
Member

@ioquatix ioquatix commented Jul 29, 2025

See #2346 for more context.

Alternatively, it could return nil, but I think returning self is slightly more useful. However, it does lock in the return value (nil might give us more flexibility in the future).

In principle with this change, one could write:

Rack::Builder.new.use(...).use(...).run(...).to_app

I'm open to either idea. WDYT.

@ioquatix ioquatix requested a review from jeremyevans July 29, 2025 07:34
Copy link
Contributor

@jeremyevans jeremyevans left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree we should be explicit in the return value. My preference is to have the methods return nil, so we can potentially use a different return value in the future. If we return self, we are basically stuck with that going forward, even if later we find it would be better to return something else. I don't think the minor benefit of supporting method chaining is worth potentially limiting ourselves in the future. If we choose to return self and not nil, we should add specs for the behavior we want to allow.

@ioquatix
Copy link
Member Author

Thanks, I'm fine with either, so I'll change it to nil.

Just for future reference, apart from nil and self would there be any other realistic option?

@ioquatix ioquatix force-pushed the rack-builder-use-return-self branch from 8678fdb to dbf39dd Compare July 30, 2025 00:15
@ioquatix ioquatix changed the title Rack::Builder #use, #run and #map all return self. Rack::Builder #use, #run and #map all return nil. Jul 30, 2025
@ioquatix ioquatix merged commit c025528 into main Jul 30, 2025
33 checks passed
@ioquatix ioquatix deleted the rack-builder-use-return-self branch July 30, 2025 00:21
@jeremyevans
Copy link
Contributor

Just for future reference, apart from nil and self would there be any other realistic option?

I'm not sure. I don't have any ideas yet. But since there's no burning need to support method chaining for this, I'd rather leave the option open.

theodorton added a commit to byroot/propshaft that referenced this pull request Aug 20, 2025
Rack::Builder#run returns nil, see rack/rack#2355
theodorton added a commit to byroot/propshaft that referenced this pull request Aug 20, 2025
Rack::Builder#run returns nil, see rack/rack#2355
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants