Ruby variable name with double underscores

Sometimes I see variable names with double underscores at the beginning and at the end. For example:

Article.__elasticsearch__ 

Is there any naming convention associated with double underscores in Ruby variable names?

+7
ruby naming-conventions double-underscore
source share
2 answers

An initial underscore or double underscore basically indicates "special / avoid overwrite" - which means that it reduces the likelihood that someone else can define a method / attribute of the same name. The most common occurrence is __send__ .

From Ruby Forum

+9
source share

ElasticSearch gemstone author incorrect IMO call. At the end of the stream, Avdi Grimm, well known in the Ruby community, disagrees with the OP .

There is a reason that you have not seen this yet and that it looks strange. This is because it is uniomatic.

+1
source share

All Articles