# Significance of Kernal.test method?

**URL:** <https://www.ruby-forum.com/t/significance-of-kernal-test-method/188995>\
**Category:** Ruby\
**Created:** [May 21, 2010, 3:51pm UTC](https://www.ruby-forum.com/t/significance-of-kernal-test-method/188995 "2010-05-21T15:51:35Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![v4\_forums](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/e95f7d/32.png) [@v4\_forums](https://www.ruby-forum.com/u/v4_forums)\
**Post date:** [May 21, 2010, 3:51pm UTC](https://www.ruby-forum.com/t/significance-of-kernal-test-method/188995/1 "2010-05-21T15:51:35Z")

</div>

Hi Team,

I am new to ruby and the best way I found to learn ruby is to  
walk-through  
some of the existing code and try understanding them how it is done.

Recently I came across this following line of code,

test(?e, File.join(dir, file))

Initially, was finding difficult to understand what’z this test is  
actually  
trying to perform on the file and eventually managed to figure out that  
its  
just checking whether the file exists or not. []  
I also realized that ‘?e’ is a command to the test method to check if  
the  
file exists. I also see that, in ruby, there is a much understandable  
and  
straight-forward way to achieve the same.

File.exist?

Just curious to know what is the advantage of using the former ‘Kernal’  
method than using the later ‘File’ api method.

Thanks  
Venkat

---

<div class="post-metadata">

**Author:** ![v4\_forums](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/e95f7d/32.png) [@v4\_forums](https://www.ruby-forum.com/u/v4_forums)\
**Post date:** [May 21, 2010, 5:27pm UTC](https://www.ruby-forum.com/t/significance-of-kernal-test-method/188995/2 "2010-05-21T17:27:36Z")

</div>

On May 21, 9:50 am, v4 forums [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> trying to perform on the file and eventually managed to figure out that its  
> just checking whether the file exists or not. []  
> I also realized that ‘?e’ is a command to the test method to check if the  
> file exists. I also see that, in ruby, there is a much understandable and  
> straight-forward way to achieve the same.
> 
> File.exist?
> 
> Just curious to know what is the advantage of using the former ‘Kernal’  
> method than using the later ‘File’ api method.

I believe #test stems for unix command line, and thus appeals to that  
flavor of developer. It is a much more concise notation the  
File.exist? or File. **fill-in-the-blank**. And though I like it’s  
brevity it has two aweful shortcomings 1) it is rather archaic and  
cryptic and 2) it’s bound to get clobbered by test frameworks!
