# Why does ARGF#binmode removed/suppressed the fitst element from ARGV?

**URL:** <https://rubytalk.org/t/why-does-argf-binmode-removed-suppressed-the-fitst-element-from-argv/67584>\
**Category:** ruby-talk\
**Created:** [26 March 2013 20:05 UTC](https://rubytalk.org/t/why-does-argf-binmode-removed-suppressed-the-fitst-element-from-argv/67584 "2013-03-26T20:05:50Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![7stud2](https://avatars.discourse-cdn.com/v4/letter/7/9de053/32.png) [@7stud2](https://rubytalk.org/u/7stud2)\
**Post date:** [26 March 2013 20:05 UTC](https://rubytalk.org/t/why-does-argf-binmode-removed-suppressed-the-fitst-element-from-argv/67584/1 "2013-03-26T20:05:50Z")

</div>

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-

&nbsp;&nbsp;&nbsp;&nbsp;p "welcome to the ARGF and ARGV learning script"  
&nbsp;&nbsp;&nbsp;&nbsp;p ARGV  
&nbsp;&nbsp;&nbsp;&nbsp;p ARGF.argv  
&nbsp;&nbsp;&nbsp;&nbsp;ARGF.argv.shift  
&nbsp;&nbsp;&nbsp;&nbsp;p ARGF.argv  
&nbsp;&nbsp;&nbsp;&nbsp;p ARGF.binmode?  
&nbsp;&nbsp;&nbsp;&nbsp;ARGF.binmode  
&nbsp;&nbsp;&nbsp;&nbsp;# Why `binmode` method call removing first item from the ARGV array.  
&nbsp;&nbsp;&nbsp;&nbsp;p ARGF.argv  
&nbsp;&nbsp;&nbsp;&nbsp;p ARGF.binmode?  
&nbsp;&nbsp;&nbsp;&nbsp;ARGV.shift  
&nbsp;&nbsp;&nbsp;&nbsp;p ARGF.read

when I ran the below from the command prompt:

&nbsp;&nbsp;&nbsp;&nbsp;D:\Rubyscript\My ruby learning days\>ruby true.rb --verbrose a.txt  
b.txt c.txt

\*Output:\*

&nbsp;&nbsp;&nbsp;&nbsp;"welcome to the ARGF and ARGV learning script"  
&nbsp;&nbsp;&nbsp;&nbsp;["--verbrose", "a.txt", "b.txt", "c.txt"]  
&nbsp;&nbsp;&nbsp;&nbsp;["--verbrose", "a.txt", "b.txt", "c.txt"]  
&nbsp;&nbsp;&nbsp;&nbsp;["a.txt", "b.txt", "c.txt"]  
&nbsp;&nbsp;&nbsp;&nbsp;false  
&nbsp;&nbsp;&nbsp;&nbsp;["b.txt", "c.txt"]  
&nbsp;&nbsp;&nbsp;&nbsp;true  
&nbsp;&nbsp;&nbsp;&nbsp;"HI! I am in \"a.txt\"\r\nLet's start to read the file here.Hi! I am  
in \"c.txt\"."

> **···**
>
> --  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).
