Question

I know there is __FILE__, __LINE__, and __send__.

From the Delegator class there are __getobj__ and __setobj__.

Is there any other useful "strange" double underscore goodness present in the Ruby standard library?

Était-ce utile?

La solution

This is a complete list for Ruby 2.1:

From delegate:

  • __getobj__ (Delegator)
  • __setobj__ (Delegator)
  • __getobj__ (SimpleDelegator)
  • __setobj__ (SimpleDelegator)

From drb:

  • __drbref
  • __drburi

From irb:

  • __evaluate__
  • __exit__

From tk:

  • All the methods start with a double underscore

Autres conseils

There's also the encoding keyword: __ENCODING__:

puts __ENCODING__ # => UTF-8
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top