Function object
In Ruby, several objects can be considered function objects, in particular Method and Proc objects. Ruby also has two kinds of objects that can be thought of as semi-function objects: UnboundMethod and block. UnboundMethods must first be bound to an object (thus becoming a Method) before they can be used as a function object. Blocks can be called like function objects, but to be used in any other capacity as an object (e.g. passed as an argument) they must first be converted to a Proc. More recently, symbols (accessed via the literal unary indicator codice_35) can also be converted to codice_36s. Using Ruby's unary codice_37 operator—equivalent to calling codice_38 on an object, and assuming that method exists—the Ruby Extensions Project created a simple hack.
Data, context and interaction
A Role is a stateless programming construct that corresponds to the end user's mental model of some entity in the system. A Role represents a collection of responsibilities. Whereas vernacular object-oriented programming speaks of objects or classes as the loci of responsibilities, DCI ascribes them to Roles. An object participating in a use case has responsibilities: those that it takes on as a result of playing a particular Role. Most modern programming languages have a way to express Roles, and to express the injection of Role methods into objects, and implementation techniques vary depending on the language. The injection can be fully dynamic at run-time in languages like Ruby and Python; it is more static in languages like Smalltalk-Squeak, Scala and C++. The Qi4j programming environment offers a way to express Role method injection into Java objects. Java 8 default method on interfaces can be used to implement Roles in a typesafe way.