Working with objects

In languages, such as Java or Ruby, you first create a class with attributes and methods, like a kind of template, and then you can create objects from that class, often by using a new constructor, like

 new ClassName(...).

Red doesn't know classes. Instead, it only uses objects, which contain data (attributes or fields) and/or functions (methods). You create objects either by cloning existing objects or starting from the base object! value. This is why Red has a prototype-based object model (instead of a class-based one)—objects are made by reusing existing objects. This model has the advantage of being simple and efficient. Other languages that work the same way for objects are JavaScript and Lua.

The Red system also ...

Get Learn Red - Fundamentals of Red now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.