4 ms·
The $: change seems bizarre.
by gfodor 16y ago
The $: change seems bizarre.
- ifesdjeen 16y agowhy so?.. i don't really get your point
- bradleyland 16y agoBecause almost everywhere else (other languages, the shell, etc), the current working directory is searched first. This makes it arbitrarily simple to package up a set of scripts in a directory, which can be unpacked and run. That seems bizarre to me as well.
- augustl 16y agoAgreed. I wonder if it's cosmetic or if you can't actually require files in the same directory as __FILE__ via the load path. Then again, this will probably only break snippets outside of projects, where lib/ is in the load path.
- manveru 16y agoUse require_relative if you want to require files relative to __FILE__, that way you don't have to worry about $LOAD_PATH and keep your sanity :)
- petercooper 16y agoHaving . in the load path led to some weird outcomes, especially to beginners. One example is if you write a script called twitter.rb that relies on a library also called 'twitter'. The require would attempt to pull in the current file rather than the library. I got stuck for a good 15 minutes with this one myself a few years ago ;-)