Pregunta

There are a lot of threads on here about this already I know but none of the titles have this worded exactly like I did. I hope that we can clear this up a bit.

$:.unshift(File.expand_path("../../lib", __FILE__)) 

You see something like this in a lot of Ruby code. Opinions vary whether this is proper or not.

Can we get a little explaination for each of its parts? There realy is a lot going on here. I only understand some of it.

¿Fue útil?

Solución

$: holds Load path for scripts and binary modules by load or require. . And Array#unshift will prepend the new path to $:. File#expand_path Converts a pathname to an absolute pathname. __FILE__ is already answered here What does __FILE__ mean in Ruby?.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top