2

what does this line mean?

$LOAD_PATH.unshift File.expand_path('../../../lib', __FILE__)
walid
  • 494
  • 3
  • 16
Adam Lee
  • 24,710
  • 51
  • 156
  • 236
  • 3
    Possible duplicate of [Understanding Ruby's load paths](http://stackoverflow.com/questions/6671318/understanding-rubys-load-paths) – Drenmi Apr 08 '17 at 04:05
  • It means that whoever wrote this doesn't understand `require_relative` and shouldn't be allowed to write Ruby code. – Jörg W Mittag Apr 08 '17 at 07:25

1 Answers1

2

$LOAD_PATH is an array. Try running $LOAD_PATH.class in irb to prove it to yourself. The unshift method of Array adds something to the beginning of the array. https://ruby-doc.org/core-2.2.0/Array.html#method-i-unshift

In this case, it adds the absolute path of the ruby file, up three directories, then down into lib. https://ruby-doc.org/core-2.2.0/File.html#method-c-expand_path