Package

org.taffy.core

What is it?

Object is the base class of everything in Taffy. It is abstract.

Classes that inherit from Object

Methods

address

Returns the address of the receiver, as a hexidecimal string.

allMethods

Returns an array, where each element is the string representation of a public methods of the object, and all of its super-objects.

Example:

[[1 allMethods] each: { <method>
    io putLine: method
}]
==> lots of methods!
allObjects

Returns an Array of Pairs that contains objects that are owned by the receiver and all its super objects. Each Pair’s left is the object’s name, and its right is the object’s value.

Example:

class Car
{
    @color, @rw
}

class Truck(Dog)
{
    @bedSize, @rw
}

truck = new Truck
truck allObjects
==> [#Pair<"@bedSize", nil>, #Pair<"@color", nil>]
asString

The default implementation of asString. It returns the class name of the receiver, like "#ClassName".

attach: slice

Add the objects and methods from the slice to the receiver. Note that this method is instance-specific and does not affect other objects of the same type.

Example:

class Dog
{
}

slice Bark
{
    (@) bark
    {
        io putLine: "ruff!"
    }
}

chihuahua = new Dog
chihuahua attach: Bark
chihuahua bark
==> ruff!
castAs: type

Cast the receiver to type. Throws InvalidCastException if the receiver does not inherit from type.

Example:

1 castAs: org.taffy.core.Object
==> #Object
copy

Deep copy the receiver and return it. The returned value’s address will differ from the receiver’s address.

class

Return the receiver’s meta-class.

Example:

1 class
==> #Number-meta
className

Return the receiver’s class name.

Example:

1 className
==> "Number"
#operator(==): other

The default equality operator implementation. Returns true if other's address equals the receiver’s address.

hash

The default hash method. Returns the receiver’s address mod 2^32 - 1.

hasMethod?: methodString

Returns true if the receiver has a method named methodString.

Example:

1 hasMethod?: "hasMethod?:"
==> true

1 hasMethod?: "foof"
==> false
init

The default constructor. Does nothing and returns the receiver.

kindOf?: classType

Returns true if the receiver inherits from classType.

Example:

[] kindOf?: Object
==> true

[] kindOf?: Hash =⇒ false

objects

Returns all the public objects of the receiver, but not its supers.

Usage Example:

[[1 objects] each: { <object>
    io putLine: object
}]
methods

Returns all the public methods of the receiver, but not its supers.

Usage Example:

[[1 methods] each: { <method>
    io putLine: method
}]
perform: selectorString

Executes the method specified by selectorString.

Example:

a = 1
a perform: "#operator(++)"
==> 2

a
==> 2
perform: selectorString with: objectsArray

Executes the method specified by selectorString, using objectsArray as the arguments.

Example:

hash = ()
[hash perform: "setValue:forKey:"
         with: [1, "one"]]
==> #Hash("one" => 1)
setValue: value forObject: object

Sets the the public, writer-enabled, variable object to value. Throws UnidentifiedObjectException if object is not public, or has no writer.

Example:

class Dog {
    @breed, @rw
}

dog = new Dog
dog setValue: "Shih Tzu" forObject: "@breed"
dog breed
==> "Shih Tzu"