# Re: File::open and File.open

**URL:** <https://www.ruby-forum.com/t/re-file-open-and-file-open/73339>\
**Category:** Ruby\
**Created:** [October 23, 2006, 10:38pm UTC](https://www.ruby-forum.com/t/re-file-open-and-file-open/73339 "2006-10-23T22:38:46Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![phrogz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/2acd7d/32.png) [@phrogz](https://www.ruby-forum.com/u/phrogz)\
**Post date:** [October 23, 2006, 10:38pm UTC](https://www.ruby-forum.com/t/re-file-open-and-file-open/73339/1 "2006-10-23T22:38:46Z")

</div>

From: Brad T.

> What exactly is the difference between these?

:: and . are interchangeable for method calls (I think fully):  
irb(main):001:0\> class Foo; attr\_accessor :bar; end  
=\> nil  
irb(main):002:0\> f = Foo.new  
=\> #Foo:0x2c9abd8  
irb(main):003:0\> f::bar  
=\> nil  
irb(main):004:0\> f::bar = 12  
=\> 12  
irb(main):005:0\> f::bar  
=\> 12

“::” must be used for constant lookup:

irb(main):001:0\> class Foo; BAR = 12; end  
=\> 12  
irb(main):002:0\> Foo::BAR  
=\> 12  
irb(main):003:0\> Foo.BAR  
NoMethodError: undefined method `BAR’ for Foo:Class  
from (irb):3

Most people (I believe) only use “::” for constants, and “.” for all  
method calls.
