Created
August 14, 2015 02:28
-
-
Save woods/15bb675c7447407a8353 to your computer and use it in GitHub Desktop.
load vs require
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
~/westarete/src/flip-learning | 30248d7 | master | |
[532] $ echo 'puts "hi"' > hello.rb | |
~/westarete/src/flip-learning | 30248d7 | master* | |
[533] $ irb | |
irb(main):001:0> require 'hello' | |
LoadError: cannot load such file -- hello | |
from /Users/woods/.rbenv/versions/2.2.2/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require' | |
from /Users/woods/.rbenv/versions/2.2.2/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require' | |
from (irb):1 | |
from /Users/woods/.rbenv/versions/2.2.2/bin/irb:11:in `<main>' | |
irb(main):002:0> require_relative './hello' | |
hi | |
=> true | |
irb(main):003:0> require_relative './hello' | |
=> false | |
irb(main):004:0> load 'hello' | |
LoadError: cannot load such file -- hello | |
from (irb):4:in `load' | |
from (irb):4 | |
from /Users/woods/.rbenv/versions/2.2.2/bin/irb:11:in `<main>' | |
irb(main):005:0> load './hello' | |
LoadError: cannot load such file -- ./hello | |
from (irb):5:in `load' | |
from (irb):5 | |
from /Users/woods/.rbenv/versions/2.2.2/bin/irb:11:in `<main>' | |
irb(main):006:0> load 'hello.rb' | |
hi | |
=> true | |
irb(main):007:0> load 'hello.rb' | |
hi | |
=> true | |
irb(main):008:0> load 'hello.rb' | |
hi | |
=> true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment