Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8083833
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T17:36:05+00:00 2026-06-05T17:36:05+00:00

I am learning Ruby from the Poignant Guide to Ruby and in some of

  • 0

I am learning Ruby from the Poignant Guide to Ruby and in some of the code examples, I came across uses of the double colon and dot that seem to be used for the same purpose:

File::open( 'idea-' + idea_name + '.txt', 'w' ) do |f|
   f << idea
end

In the above code, the double colon is being used to access the open method of the File class. However, I later came across code that used a dot for the same purpose:

require 'wordlist'
# Print each idea out with the words fixed
Dir['idea-*.txt'].each do |file_name|
   idea = File.read( file_name )
   code_words.each do |real, code| 
     idea.gsub!( code, real )
   end
puts idea
end 

This time, a dot is being used to access the read method of the File class. What is the difference between:

File.read()

and

File::open()
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T17:36:07+00:00Added an answer on June 5, 2026 at 5:36 pm

    It’s the scope resolution operator.

    An example from Wikipedia:

    module Example
      Version = 1.0
    
      class << self # We are accessing the module's singleton class
        def hello(who = "world")
           "Hello #{who}"
        end
      end
    end #/Example
    
    Example::hello # => "Hello world"
    Example.hello "hacker" # => "Hello hacker"
    
    Example::Version # => 1.0
    Example.Version # NoMethodError
    
    # This illustrates the difference between the message (.) operator and the scope
    # operator in Ruby (::).
    # We can use both ::hello and .hello, because hello is a part of Example's scope
    # and because Example responds to the message hello.
    #
    # We can't do the same with ::Version and .Version, because Version is within the
    # scope of Example, but Example can't respond to the message Version, since there
    # is no method to respond with.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

A few years back, I started learning Ruby/Rails from some beginner's guide for Rails.
I am learning ruby from a book I got called The Pragmatic Programmers Guide
I am new to Ruby and am learning from reading an already written code.
I am learning ruby from this guide http://ruby.railstutorial.org/ruby-on-rails-tutorial-book#sec:deploying , and I am trying to
I am coming from the world of PHP and am learning Ruby/Rails. I have
I'm learning Ruby and I've seen a couple of methods that are confusing me
I'm just learning Ruby and making a simple Hello World program, put for some
I'm currently learning Ruby and RoR and I stumbled across this declaration: link_to_remote(name, options
I am learning ruby and practicing it by solving problems from Project Euler .
I come from more of a C# background yet am learning Ruby in my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.