Ruby (programming language)
Ruby has been described as a multi-paradigm programming language: it allows procedural programming (defining functions/variables outside classes makes them part of the root, 'self' Object), with object orientation (everything is an object) or functional programming (it has anonymous functions, closures, and continuations; statements all have values, and functions return the last evaluation). It has support for introspection, reflection and metaprogramming, as well as support for interpreter-based threads. Ruby features dynamic typing, and supports parametric polymorphism.
Uniform access principle
The above initial code segment would work fine with the Egg being defined as such. The Egg
class could also be defined as below, where color is instead a method. The calling code would
still work, unchanged if Egg were to be defined as follows.
Note how even though codice_1 looks like an attribute in one case and a pair of methods
in the next, the interface to the class remains the same. The person maintaining the Egg class can switch from one form to the other without fear of breaking any caller's code.
Ruby follows the revised UAP, the codice_2 only acts as syntactic sugar for generating accessor/setter methods for codice_1. There is no way in Ruby to retrieve an instance variable from an object without calling a method on it.