Created
May 2, 2014 02:15
-
-
Save mathildathompson/9339ffe912501c1ee74f to your computer and use it in GitHub Desktop.
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
require 'pry' | |
binding.pry | |
ruby reader.rb groucho harpo chico #Ruby load this file and pass in 3 arguments; | |
ARGV #This is the argments array that you passed into the programme when you ran it; | |
puts ARGV.join(', ') | |
if(ARGV[0] == 'groucho') | |
puts "Hey there Groucho" | |
end | |
When you run rails server #Server is the argument | |
touch brothers.txt | |
ruby reader.rb brothers.txt | |
ARGV => ["brothers.txt"] | |
ARGF.each do {|line| puts line } | |
#Mention file names in ARGV then you are interate through the contents of the file with ARGF; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment