I have been introduced to the class ARGF
today. I was trying each of
the methods of this class to see how they work. Doing so below sample
made me confused.
File name: true.rb
contains the below code-
p "welcome to the ARGF and ARGV learning script"
p ARGV
p ARGF.argv
ARGF.argv.shift
p ARGF.argv
p ARGF.binmode?
ARGF.binmode
# Why `binmode` method call removing first item from the ARGV array.
p ARGF.argv
p ARGF.binmode?
ARGV.shift
p ARGF.read
when I ran the below from the command prompt:
D:\Rubyscript\My ruby learning days>ruby true.rb --verbrose a.txt
b.txt c.txt
Output:
"welcome to the ARGF and ARGV learning script"
["--verbrose", "a.txt", "b.txt", "c.txt"]
["--verbrose", "a.txt", "b.txt", "c.txt"]
["a.txt", "b.txt", "c.txt"]
false
["b.txt", "c.txt"]
true
"HI! I am in \"a.txt\"\r\nLet's start to read the file here.Hi! I am
in “c.txt”."