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 8782415
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T20:33:16+00:00 2026-06-13T20:33:16+00:00

I recently found an interesting article on implicit contexts in Ruby, and I found

  • 0

I recently found an interesting article on implicit contexts in Ruby, and I found the experience quite mind opening.
I understood that Ruby holds a reference not only to self (the default method receiver), but also to the current class (also known as default definee or `klass').

From the article, It should be correct to assume that class definition sets both self and the current class to the class that is being defined; as far as we consider normal method definition (i.e. not using the dot syntax to define singleton methods), in the context of method definition with def, self refers to the receiving object, and the current class isn’t changed.

The reason i find safe to not consider the dot syntax for defining is that Ruby also offers an explicit way to open the eigenclass of a class, and the very thing I’m interested is understanding how these two implicit contexts are managed when opening a eigenclass.

Using def with the well known syntax for opening a eigenclass:

class << A
  p self

  def foo
    # ...
  end
end

defines foo as a singleton method of A, i.e. an instance method of its eigenclass (be it A'). This code also prints #<Class:A>, so is it correct to say that the << syntax sets both self and the current class to A'?

  • 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-13T20:33:17+00:00Added an answer on June 13, 2026 at 8:33 pm

    Yes it actually opens the block under the control of A’.
    Also you can say that it works like class_eval of A’.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I recently found that dynamically creating object and methods in Ruby is quite a
I recently came across the link below which I have found quite interesting. http://en.wikipedia.org/wiki/XOR_linked_list
I've recently found an interesting alternative to the ASP.NET MVC that I currently do:
recently found an article in http://hashtwo.com/blog/integrating-a-file-browser-into-ckeditor-cakephp to integrate a file browser into ckeditor (file
I recently found that one of my services was taking a large amount of
I recently found myself writing a piece of code that executed a Core Data
I recently read this article on GWT Lightweight Metrics and found it intriguing, but
I recently found a interesting behaviour of g++ when compared with MSVC++ 2008. Consider
I recently started to learn node.js + Express and found it very interesting. I
I recently found out that PHP 5.3 supports new language construct called GOTO .

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.