Objects

All values in Ferret are objects. But what does that actually mean? All values can have properties.

3.odd           # true
16.sqrt         # 4
"hi".length     # 2
(1+2i).abs      # 2.23607

An object is the simplest data type of all in Ferret, and all other values inherit from it. A plain object is constructed like so.

$o = (propName: "value", other: 11)

Only bareword keys called properties are allowed for objects, but the corresponding values can be any type.

The properties propName and other defined above are accessed using property notation. They can be assigned to this way as well.

say($o.propName)
$o.other = "I changed the type from Num to Str"
$o.newOne = "You can also define new properties this way"
$o.nonexistent  # accessing nonexistent properties produces no error

The empty object looks like this and has no properties.

(:)

Next: Functions