4 ms·
I wish ruby went with hard/explicit imports like python or js. Solves this problem and "magic" that so many complain about while retaining all the other great
by irjustin 1y ago
I wish ruby went with hard/explicit imports like python or js.
Solves this problem and "magic" that so many complain about while retaining all the other great things to love about Ruby.
- bm5k 1y agoEw. No.
- zoky 1y agoI mean, nothing is stopping you from doing something like: require 'foo' Bar = Foo::Bar
- PufPufPuf 1y agoMost definitely. When I worked with existing Ruby codebases, it was surprisingly hard to answer the question "where is this defined" when every import is dumped into a single global namespace. I had no idea where stuff came from, and neither the IDE.
- sethrin 1y agoUse the `method` method to get a reference to the one you are concerned with, then call `source_location` on it.
- irjustin 1y agoThat's only during runtime. Simply reading code can be annoyingly difficult without hard references. Especially when the code is coming from a gem. Many times LSP's can't figure out where the code is coming from if it's a few layers deep. Then you're stuck with the time consuming method of running the code and doing something like what you're describing above just to read it.