Skip to content
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

Toplevel [] method for YAML? #679

Open
rubyFeedback opened this issue Aug 1, 2024 · 1 comment
Open

Toplevel [] method for YAML? #679

rubyFeedback opened this issue Aug 1, 2024 · 1 comment

Comments

@rubyFeedback
Copy link

rubyFeedback commented Aug 1, 2024

Would it be possible to alias YAML[] onto YAML.load_file()?

E. g.:

x = YAML.load_file('foobar.yml')
x = YAML['foobar.yml']

Rationale:

Laziness (or "user efficiency" - anything to type less, just as require 'pp' is no longer necessary. :D

@headius
Copy link
Contributor

headius commented Aug 1, 2024

Is there any precedent for such an alias? Are there other libraries that alias one of their methods to a module-level []? I have to admit it looks a little weird to my eyes.

There's another Ruby quirk that could be used instead: YAML.(), which Ruby treats as a call to YAML.call. The more you know! 🌠

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants