• Post Reply Bookmark Topic Watch Topic
  • New Topic

What is the meaning of "class <<"?  RSS feed

 
Alejandro Barrero
Ranch Hand
Posts: 376
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In a discussion of Solitaire Cipher I found the code

The code appears to use @keystream as as an object of those methods, but I have not seen this any where.
 
Alejandro Barrero
Ranch Hand
Posts: 376
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I found that an anonymous (singleton) class is associated with the specific object, so it is possible to add several methods.
 
Ronald Otto
Greenhorn
Posts: 3
Linux Mac OS X Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Alejandro Barrero wrote:I found that an anonymous (singleton) class is associated with the specific object, so it is possible to add several methods.


See this discussion:

http://openmymind.net/2010/6/25/Learning-Ruby-class-self/

I prefer creating Singleton classes using the "extend self" idiom.

Both options are described here: https://blog.engineyard.com/2015/instances-classes-and-modules
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!